@principles/workbuddy-adapter 0.7.0 → 0.7.1
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.
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
import fs from 'node:fs';
|
|
33
33
|
import path from 'node:path';
|
|
34
34
|
import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, } from '@principles/core/runtime';
|
|
35
|
-
import { loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, createGovernanceTrajectoryTurnReader, createHostIntentDocReader, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
|
|
35
|
+
import { loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, createGovernanceTrajectoryTurnReader, createHostIntentDocReader, isAutomaticPainSubmissionAuthorized, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
|
|
36
36
|
import { WORKBUDDY_TOOL_SEMANTICS, WORKBUDDY_TOOL_SEMANTIC_MAPPINGS } from '../tool-semantics.js';
|
|
37
37
|
import { catchUpWorkbuddyIngestion } from '../ingestion/catch-up.js';
|
|
38
38
|
const WORKER_OWNER = 'companion-worker';
|
|
@@ -172,6 +172,9 @@ export async function runWorkbuddyWorkspaceWorkerCycle(options) {
|
|
|
172
172
|
// PRI-1265: the worker's Stage A gets the bound session's ORIGINAL
|
|
173
173
|
// turns from the workspace's own consent-tiered governance store.
|
|
174
174
|
trajectoryTurnReader: createGovernanceTrajectoryTurnReader({ workspaceDir }),
|
|
175
|
+
// SPEC §9.6: lazy probe — a revoked flag stops persisted
|
|
176
|
+
// automatic_hook tasks at the bridge's execution boundary.
|
|
177
|
+
isAutoPainSubmissionAuthorized: () => isAutomaticPainSubmissionAuthorized(workspaceDir),
|
|
175
178
|
});
|
|
176
179
|
const executed = await bridge.executePendingDiagnosis({ taskId: candidate.taskId });
|
|
177
180
|
diagnostician = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/workbuddy-adapter",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "WorkBuddy host adapter for Principles Disciple — implements the HostAdapter interface for WorkBuddy's Git Bash command-hook model (ADR-0020 third host, SPEC workbuddy-host-adapter v0.3.0).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"lint": "eslint \"src/**/*.ts\""
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@principles/core": "^8.0.
|
|
46
|
-
"@principles/host-runtime": "^4.5.
|
|
47
|
-
"@principles/install-layout": "^0.9.
|
|
45
|
+
"@principles/core": "^8.0.1",
|
|
46
|
+
"@principles/host-runtime": "^4.5.1",
|
|
47
|
+
"@principles/install-layout": "^0.9.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/node": "^26.6.6",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "44eb2260606776dc28939a45d5375c2fb29b4a0c"
|
|
65
65
|
}
|
package/plugin/mcp/launcher.cjs
CHANGED
|
@@ -435,6 +435,33 @@ function readAbsoluteWorkspaceField(parsed, field) {
|
|
|
435
435
|
* Comparison uses canonical directory identity so a junction, alias or case
|
|
436
436
|
* difference cannot smuggle one host's tree past another host's claim.
|
|
437
437
|
*/
|
|
438
|
+
/**
|
|
439
|
+
* Read the workspaceDir of another host's persisted payload binding, but only
|
|
440
|
+
* when the binding passes the SAME full shape validation the launcher applies
|
|
441
|
+
* to its own binding (schemaVersion, host marker, absolute workspaceDir/
|
|
442
|
+
* runtimeDir/serverEntry, semver versions.mcpServer, canonical server entry).
|
|
443
|
+
* A binding that would fail launch-time validation cannot form a workspace
|
|
444
|
+
* claim — fail-closed, mirroring `readWorkspaceFromBinding` in
|
|
445
|
+
* @principles/install-layout.
|
|
446
|
+
*/
|
|
447
|
+
function payloadBindingWorkspaceClaim(file, host) {
|
|
448
|
+
const parsed = readJson(file);
|
|
449
|
+
if (parsed === undefined) return undefined;
|
|
450
|
+
if (parsed.schemaVersion !== BINDING_SCHEMA) return undefined;
|
|
451
|
+
if (parsed.host !== host) return undefined;
|
|
452
|
+
if (typeof parsed.workspaceDir !== 'string' || !path.isAbsolute(parsed.workspaceDir.trim())) return undefined;
|
|
453
|
+
if (typeof parsed.runtimeDir !== 'string' || !path.isAbsolute(parsed.runtimeDir.trim())) return undefined;
|
|
454
|
+
if (typeof parsed.serverEntry !== 'string' || !path.isAbsolute(parsed.serverEntry.trim())) return undefined;
|
|
455
|
+
if (!isRecord(parsed.versions) || typeof parsed.versions.mcpServer !== 'string' || !SEMVER.test(parsed.versions.mcpServer)) return undefined;
|
|
456
|
+
// getCanonicalMcpServerEntry mirror: Codex uses the npm-dependency layout,
|
|
457
|
+
// the shared-runtime hosts the component layout.
|
|
458
|
+
const canonical = host === 'codex'
|
|
459
|
+
? path.join(parsed.runtimeDir, 'node_modules', '@principles', 'pd-mcp-server', 'dist', 'index.js')
|
|
460
|
+
: path.join(parsed.runtimeDir, 'pd-mcp-server', 'dist', 'index.js');
|
|
461
|
+
if (!samePath(parsed.serverEntry, canonical)) return undefined;
|
|
462
|
+
return path.resolve(parsed.workspaceDir.trim());
|
|
463
|
+
}
|
|
464
|
+
|
|
438
465
|
function hostDeclaredWorkspaceClaims(roots) {
|
|
439
466
|
const claims = [];
|
|
440
467
|
const declarationFiles = [
|
|
@@ -449,17 +476,26 @@ function hostDeclaredWorkspaceClaims(roots) {
|
|
|
449
476
|
const dataRoot = path.join(roots.codexHome, 'plugins', 'data');
|
|
450
477
|
for (const entry of fs.readdirSync(dataRoot)) {
|
|
451
478
|
if (typeof entry !== 'string' || !entry.startsWith('principles-disciple-')) continue;
|
|
452
|
-
const bound =
|
|
479
|
+
const bound = payloadBindingWorkspaceClaim(path.join(dataRoot, entry, 'mcp-binding.json'), 'codex');
|
|
453
480
|
if (bound !== undefined) claims.push({ host: 'codex', workspaceDir: bound });
|
|
454
481
|
}
|
|
455
482
|
} catch {
|
|
456
483
|
// No Codex plugin data on this machine — nothing to claim.
|
|
457
484
|
}
|
|
458
|
-
const wbBound =
|
|
459
|
-
|
|
460
|
-
'
|
|
485
|
+
const wbBound = payloadBindingWorkspaceClaim(
|
|
486
|
+
path.join(roots.homeDir, '.pd', 'workbuddy-marketplace', 'principles-disciple', 'mcp-binding.json'),
|
|
487
|
+
'workbuddy',
|
|
461
488
|
);
|
|
462
489
|
if (wbBound !== undefined) claims.push({ host: 'workbuddy', workspaceDir: wbBound });
|
|
490
|
+
// P0-1: the OpenClaw plugin persists its own binding beside its installed
|
|
491
|
+
// extension (<openclawHome>/extensions/principles-disciple/mcp-binding.json).
|
|
492
|
+
// Without this read, a non-default workspace OpenClaw bound via
|
|
493
|
+
// PD_WORKSPACE_DIR/OPENCLAW_WORKSPACE was invisible to ownership checks.
|
|
494
|
+
const ocBound = payloadBindingWorkspaceClaim(
|
|
495
|
+
path.join(roots.openclawHome, 'extensions', 'principles-disciple', 'mcp-binding.json'),
|
|
496
|
+
'openclaw',
|
|
497
|
+
);
|
|
498
|
+
if (ocBound !== undefined) claims.push({ host: 'openclaw', workspaceDir: ocBound });
|
|
463
499
|
return claims;
|
|
464
500
|
}
|
|
465
501
|
|
|
@@ -7,11 +7,17 @@ description: 记录一条"相对锚点的显著行为背离"(Pain)。Owner
|
|
|
7
7
|
|
|
8
8
|
# PD Pain Signal(WorkBuddy)
|
|
9
9
|
|
|
10
|
-
Pain
|
|
10
|
+
Pain 是定位和触发信号,不是数据集样本本体;样本单位是有完整上下文的行为偏差事件。必须在具体 Owner、任务和决策时点中,比较宿主行为与当时可证实的用户预期、意图及适用 PD 原则。任务成功仍可能偏离;任务失败也不自动意味着偏离。不得把“少询问、执行快、检查多”等行为风格当作普遍更好。
|
|
11
|
+
|
|
12
|
+
完整事件需要关联原始相关对话轨迹、工具调用与返回、产物和状态变化;摘要不能替代原始轨迹。区分当时宿主有机会获知的期望、事后澄清和评价者推断。完整归档可以包含后续纠正,但不得将后续信息泄漏给更早的决策点评测。完整轨迹暂不可用时,不要因此丢弃合法 Pain:按现有授权入口保存可验证信号与来源线索,明确保留为不完整候选,不得宣称完整样本,也不得绕过留存授权补齐。
|
|
13
|
+
|
|
14
|
+
规范详见 [PD 行为偏差事件与相对评价规范](https://github.com/csuzngjh/principles/blob/main/docs/concepts/PD_BEHAVIOR_DEVIATION_EVENT_AND_RELATIVE_EVALUATION.md)。当前提交接口仍要求一个主锚点;这是入口字段约束,不代表完整事件只包含一个期望依据。额外期望或原则冲突应在 reason 中如实保留。
|
|
15
|
+
|
|
16
|
+
当前提交接口的主锚点仍需满足以下要求:
|
|
11
17
|
|
|
12
18
|
1. **锚点** —— Owner 的明示要求、既有原则,或生效中的 Agent 指令 / Skill 要求。
|
|
13
19
|
2. **具体行为** —— 你实际做了什么、漏了什么。
|
|
14
|
-
3.
|
|
20
|
+
3. **具体可说明的背离** —— 相对该锚点可以说清楚的差距;影响大小、重复次数和情绪强度不是提交门槛。
|
|
15
21
|
|
|
16
22
|
没有证明影响、没有重复发生、Owner 之前没纠正过,都**不是**不提交的理由,只影响 Owner 的注意力排序。
|
|
17
23
|
|
|
@@ -76,6 +82,8 @@ Owner 说过 —— 本次对话、Owner 文档或已批准的决定。`anchorRe
|
|
|
76
82
|
|
|
77
83
|
## `reason` —— 六部分,按顺序
|
|
78
84
|
|
|
85
|
+
以下六部分描述当前提交入口需要表达的主锚点,不等于完整事件的数据模型。完整事件中的事后澄清和评价者推断必须分开保存,不能冒充 Owner 原话或宿主当时已知的要求;只有推断不足以满足当前有锚点提交约束时,可以保留为待核验材料,不得伪装成已验证偏差。
|
|
86
|
+
|
|
79
87
|
1. **锚点** —— 引用或指明(原则 id@version、指令 path#section、Owner 原话 + 出处)。
|
|
80
88
|
2. **锚点来源与引用等级** —— `verbatim` / `paraphrase` / `recollection` / `inference`。不得抬高等级。仅有 `recollection` 或 `inference` 时不够:先与 Owner 确认原话。
|
|
81
89
|
3. **观察到的行为** —— 具体动作、顺序、跳过的步骤、越界之处。不要写"质量不好"。
|