create-principles-disciple 1.147.17 → 1.147.19
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/_release/product-identity.json +1 -1
- package/codex-adapter/package.json +1 -1
- package/core/dist/host/host-installer.d.ts +11 -0
- package/core/dist/host/host-installer.d.ts.map +1 -1
- package/core/dist/host/host-installer.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +20 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +75 -12
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts +21 -0
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +105 -4
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/installers/workbuddy-host-installer.d.ts +34 -3
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +841 -53
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/dist/utils/config-file-io.d.ts +27 -1
- package/dist/utils/config-file-io.d.ts.map +1 -1
- package/dist/utils/config-file-io.js +78 -3
- package/dist/utils/config-file-io.js.map +1 -1
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/index.d.ts +49 -0
- package/install-layout/dist/index.js +59 -0
- package/install-layout/package.json +1 -1
- package/package.json +4 -4
- package/pd-cli/dist/commands/health-workbuddy.d.ts +31 -0
- package/pd-cli/dist/commands/health-workbuddy.d.ts.map +1 -0
- package/pd-cli/dist/commands/health-workbuddy.js +192 -0
- package/pd-cli/dist/commands/health-workbuddy.js.map +1 -0
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +12 -0
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +110 -110
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +75 -12
- package/release-manager/dist/installers/codex-host-installer.js +105 -4
- package/release-manager/dist/installers/workbuddy-host-installer.js +841 -53
- package/release-manager/dist/utils/config-file-io.js +78 -3
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/package.json +1 -1
|
@@ -12,6 +12,48 @@ export function errnoCode(value) {
|
|
|
12
12
|
* target with exclusive sharing surfaces as these on Windows. Transient by
|
|
13
13
|
* nature — the host rewrites its settings periodically and releases. */
|
|
14
14
|
const RETRYABLE_RENAME_ERRNOS = new Set(['EPERM', 'EBUSY', 'EACCES']);
|
|
15
|
+
/**
|
|
16
|
+
* The target changed after the transaction snapshot; guarded replacement was
|
|
17
|
+
* refused. `committed: false` means this writer did NOT replace the target.
|
|
18
|
+
*
|
|
19
|
+
* LIMIT (must not be described as a CAS): POSIX/Windows filesystems expose no
|
|
20
|
+
* portable compare-and-swap rename. The guard re-reads and byte-compares
|
|
21
|
+
* immediately before each rename, which narrows but CANNOT eliminate the
|
|
22
|
+
* cross-process window between that read and the rename itself. A concurrent
|
|
23
|
+
* write landing inside that window is not detectable here; callers must keep
|
|
24
|
+
* the original snapshot as manual-recovery evidence instead of claiming the
|
|
25
|
+
* concurrent edit survived.
|
|
26
|
+
*/
|
|
27
|
+
export class AtomicReplaceConflictError extends Error {
|
|
28
|
+
committed = false;
|
|
29
|
+
filePath;
|
|
30
|
+
/** Private temp dir left behind when cleanup also failed (manual review). */
|
|
31
|
+
residueDir;
|
|
32
|
+
constructor(filePath, residueDir, cleanupDetail) {
|
|
33
|
+
const residue = residueDir !== undefined
|
|
34
|
+
? `; temporary write residue preserved at ${residueDir}` +
|
|
35
|
+
(cleanupDetail !== undefined ? ` (${cleanupDetail})` : '')
|
|
36
|
+
: '';
|
|
37
|
+
super(`Atomic replacement refused because ${filePath} changed after the transaction snapshot${residue}. ` +
|
|
38
|
+
'This is a best-effort byte guard, NOT an atomic compare-and-swap: a concurrent write landing in the final read-then-rename window cannot be ruled out.');
|
|
39
|
+
this.name = 'AtomicReplaceConflictError';
|
|
40
|
+
this.filePath = filePath;
|
|
41
|
+
this.residueDir = residueDir;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** The target rename committed, but cleanup of the private temp directory failed. */
|
|
45
|
+
export class AtomicReplaceCleanupError extends Error {
|
|
46
|
+
committed = true;
|
|
47
|
+
filePath;
|
|
48
|
+
tempDir;
|
|
49
|
+
constructor(filePath, tempDir, cleanupError) {
|
|
50
|
+
const detail = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
51
|
+
super(`Atomic replacement committed at ${filePath}, but temporary directory cleanup failed at ${tempDir}: ${detail}`);
|
|
52
|
+
this.name = 'AtomicReplaceCleanupError';
|
|
53
|
+
this.filePath = filePath;
|
|
54
|
+
this.tempDir = tempDir;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
15
57
|
function sleepSync(milliseconds) {
|
|
16
58
|
if (milliseconds <= 0)
|
|
17
59
|
return;
|
|
@@ -22,7 +64,7 @@ function sleepSync(milliseconds) {
|
|
|
22
64
|
* WorkBuddy host holds settings.json while running and a single-attempt
|
|
23
65
|
* rename turned minutes of installer work into a full rollback. */
|
|
24
66
|
// eslint-disable-next-line @typescript-eslint/max-params -- fs-ops seam + retry options; merging them would break every existing ops caller
|
|
25
|
-
export function atomicReplaceTextFile(filePath, content, ops = FILE_OPS, retry = {}) {
|
|
67
|
+
export function atomicReplaceTextFile(filePath, content, ops = FILE_OPS, retry = {}, expectedCurrentBytes) {
|
|
26
68
|
const maxAttempts = Math.max(1, retry.maxAttempts ?? 5);
|
|
27
69
|
const wait = retry.sleep ?? sleepSync;
|
|
28
70
|
const tempDir = ops.mkdtempSync(path.join(path.dirname(filePath), '.pd-config-write-'));
|
|
@@ -32,12 +74,35 @@ export function atomicReplaceTextFile(filePath, content, ops = FILE_OPS, retry =
|
|
|
32
74
|
let operationError;
|
|
33
75
|
try {
|
|
34
76
|
fd = ops.openSync(tempPath, fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_EXCL, 0o600);
|
|
35
|
-
|
|
77
|
+
if (typeof content === 'string')
|
|
78
|
+
ops.writeFileSync(fd, content, 'utf8');
|
|
79
|
+
else
|
|
80
|
+
ops.writeFileSync(fd, content);
|
|
36
81
|
ops.fsyncSync(fd);
|
|
37
82
|
ops.closeSync(fd);
|
|
38
83
|
fd = undefined;
|
|
39
84
|
for (let attempt = 0;; attempt += 1) {
|
|
40
85
|
try {
|
|
86
|
+
// A rollback caller supplies the exact bytes PD previously wrote.
|
|
87
|
+
// Revalidate at the commit boundary on every retry so an edit observed
|
|
88
|
+
// before the rename is not replaced by a stale snapshot. This is a
|
|
89
|
+
// best-effort guard, NOT an atomic CAS: the read and the rename are two
|
|
90
|
+
// separate syscalls and a non-cooperating process can write between
|
|
91
|
+
// them. See AtomicReplaceConflictError for the documented limit.
|
|
92
|
+
if (expectedCurrentBytes !== undefined) {
|
|
93
|
+
let currentBytes;
|
|
94
|
+
try {
|
|
95
|
+
currentBytes = Buffer.from(ops.readFileSync(filePath));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (errnoCode(error) === 'ENOENT')
|
|
99
|
+
throw new AtomicReplaceConflictError(filePath);
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
if (!currentBytes.equals(Buffer.from(expectedCurrentBytes))) {
|
|
103
|
+
throw new AtomicReplaceConflictError(filePath);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
41
106
|
ops.renameSync(tempPath, filePath);
|
|
42
107
|
operationError = undefined;
|
|
43
108
|
break;
|
|
@@ -81,12 +146,22 @@ export function atomicReplaceTextFile(filePath, content, ops = FILE_OPS, retry =
|
|
|
81
146
|
}
|
|
82
147
|
}
|
|
83
148
|
if (operationError !== undefined && cleanupError !== undefined) {
|
|
149
|
+
// A guarded conflict is the authoritative verdict (rename never committed).
|
|
150
|
+
// Surface it with the residue path instead of an opaque AggregateError, so
|
|
151
|
+
// the rollback can report the real state and preserve recovery evidence.
|
|
152
|
+
if (operationError instanceof AtomicReplaceConflictError) {
|
|
153
|
+
const detail = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
154
|
+
throw new AtomicReplaceConflictError(operationError.filePath, tempDir, detail);
|
|
155
|
+
}
|
|
84
156
|
throw new AggregateError([operationError, cleanupError], 'Atomic config replacement and cleanup both failed');
|
|
85
157
|
}
|
|
86
158
|
if (operationError !== undefined)
|
|
87
159
|
throw operationError instanceof Error ? operationError : new Error(String(operationError));
|
|
88
|
-
if (cleanupError !== undefined)
|
|
160
|
+
if (cleanupError !== undefined) {
|
|
161
|
+
if (replaced)
|
|
162
|
+
throw new AtomicReplaceCleanupError(filePath, tempDir, cleanupError);
|
|
89
163
|
throw cleanupError instanceof Error ? cleanupError : new Error(String(cleanupError));
|
|
164
|
+
}
|
|
90
165
|
}
|
|
91
166
|
function readLockPid(lockPath, ops) {
|
|
92
167
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-file-io.js","sourceRoot":"","sources":["../../src/utils/config-file-io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAgBlC,MAAM,QAAQ,GAAkB,EAAE,CAAC;AAEnC,mFAAmF;AACnF,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IACnG,MAAM,EAAE,IAAI,EAAE,GAAG,KAA2B,CAAC;IAC7C,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACrD,CAAC;AAED;;wEAEwE;AACxE,MAAM,uBAAuB,GAAG,IAAI,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AC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,SAAS,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,iCAAiC,QAAQ,YAAY,MAAM,IAAI;YAC/D,iFAAiF,CAClF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,IAAI,WAAW,CAAC,QAAQ,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG;YAAE,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC"}
|
|
@@ -136,6 +136,55 @@ export declare function getMcpServerEntry(paths: InstallLayoutPaths): string;
|
|
|
136
136
|
* fallback to another host's database.
|
|
137
137
|
*/
|
|
138
138
|
export declare function getWorkbuddyWorkspaceDir(homeDir: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* The ONE registration/enablement state definition shared by the installer
|
|
141
|
+
* (install summary + `status`) and pd-cli (`pd health --host workbuddy`).
|
|
142
|
+
* Pure: no fs, no env — callers read the host files and hand the parsed
|
|
143
|
+
* values in. Neither fact may be inferred from the other (SPEC §6.4
|
|
144
|
+
* install ≠ enable); an unreadable source must never collapse into a
|
|
145
|
+
* definite value.
|
|
146
|
+
*/
|
|
147
|
+
export declare const WORKBUDDY_PLUGIN_NAME = "principles-disciple";
|
|
148
|
+
export declare const WORKBUDDY_MARKETPLACE_NAME = "principles-disciple-market";
|
|
149
|
+
/** Registry/settings key: "principles-disciple@principles-disciple-market". */
|
|
150
|
+
export declare const WORKBUDDY_PLUGIN_KEY = "principles-disciple@principles-disciple-market";
|
|
151
|
+
export interface WorkbuddyPluginStateView {
|
|
152
|
+
/** The host registry (installed_plugins.json) carries the PD plugin entry. */
|
|
153
|
+
readonly registered: boolean;
|
|
154
|
+
/** False when the registry file could not be read/parsed — installed must NOT be claimed. */
|
|
155
|
+
readonly registryReadable: boolean;
|
|
156
|
+
/** `enabledPlugins[key]`: true/false, or null when absent/unreadable/non-boolean (activation unknown). */
|
|
157
|
+
readonly enabled: boolean | null;
|
|
158
|
+
}
|
|
159
|
+
export interface WorkbuddyHostConfigPaths {
|
|
160
|
+
/** Host config root (the engine honors WORKBUDDY_CONFIG_DIR when set). */
|
|
161
|
+
readonly configDir: string;
|
|
162
|
+
readonly settingsPath: string;
|
|
163
|
+
readonly registryPath: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Resolve the WorkBuddy HOST config paths from one authority. The frozen
|
|
167
|
+
* governance dir (~/.workbuddy/pd-workspace) defines the config root;
|
|
168
|
+
* WORKBUDDY_CONFIG_DIR is the isolation override (Phase 0 lab discipline).
|
|
169
|
+
* The WorkBuddyHostInstaller resolves its full path set by delegating here,
|
|
170
|
+
* so installer / status / health can never disagree about where the host
|
|
171
|
+
* files live.
|
|
172
|
+
*/
|
|
173
|
+
export declare function getWorkbuddyHostConfigPaths(homeDir: string, configDirOverride?: string): WorkbuddyHostConfigPaths;
|
|
174
|
+
/**
|
|
175
|
+
* The shared plugin-state judgment (rc-2: no `as` bypass; rc-4/5). The exact
|
|
176
|
+
* semantics the installer has applied since PR #2355, extracted so pd-cli
|
|
177
|
+
* health reports the SAME three facts from the same rules:
|
|
178
|
+
* - registered: registry readable AND carried a plugins mapping with our key;
|
|
179
|
+
* - registryReadable: false only when the registry could not be read/parsed;
|
|
180
|
+
* - enabled: the boolean in settings.enabledPlugins[our key], or null when
|
|
181
|
+
* settings are unreadable, the key is absent, or the value is not boolean.
|
|
182
|
+
*/
|
|
183
|
+
export declare function interpretWorkbuddyPluginState(input: {
|
|
184
|
+
registryParsed: unknown;
|
|
185
|
+
settingsParsed: unknown;
|
|
186
|
+
registryReadable: boolean;
|
|
187
|
+
}): WorkbuddyPluginStateView;
|
|
139
188
|
export declare function resolveInstallLayout(options: ResolveInstallLayoutOptions): LayoutResolution;
|
|
140
189
|
export declare function getConsoleServerEntry(paths: InstallLayoutPaths, mode: InstallLayoutMode): string;
|
|
141
190
|
export declare function getConsoleWebIndex(paths: InstallLayoutPaths, mode: InstallLayoutMode): string;
|
|
@@ -164,6 +164,65 @@ export function getMcpServerEntry(paths) {
|
|
|
164
164
|
export function getWorkbuddyWorkspaceDir(homeDir) {
|
|
165
165
|
return path.join(path.resolve(homeDir), '.workbuddy', 'pd-workspace');
|
|
166
166
|
}
|
|
167
|
+
// ─── WorkBuddy host state (2026-11-07, read-only state contract) ────────────
|
|
168
|
+
/**
|
|
169
|
+
* The ONE registration/enablement state definition shared by the installer
|
|
170
|
+
* (install summary + `status`) and pd-cli (`pd health --host workbuddy`).
|
|
171
|
+
* Pure: no fs, no env — callers read the host files and hand the parsed
|
|
172
|
+
* values in. Neither fact may be inferred from the other (SPEC §6.4
|
|
173
|
+
* install ≠ enable); an unreadable source must never collapse into a
|
|
174
|
+
* definite value.
|
|
175
|
+
*/
|
|
176
|
+
export const WORKBUDDY_PLUGIN_NAME = 'principles-disciple';
|
|
177
|
+
export const WORKBUDDY_MARKETPLACE_NAME = 'principles-disciple-market';
|
|
178
|
+
/** Registry/settings key: "principles-disciple@principles-disciple-market". */
|
|
179
|
+
export const WORKBUDDY_PLUGIN_KEY = `${WORKBUDDY_PLUGIN_NAME}@${WORKBUDDY_MARKETPLACE_NAME}`;
|
|
180
|
+
/**
|
|
181
|
+
* Resolve the WorkBuddy HOST config paths from one authority. The frozen
|
|
182
|
+
* governance dir (~/.workbuddy/pd-workspace) defines the config root;
|
|
183
|
+
* WORKBUDDY_CONFIG_DIR is the isolation override (Phase 0 lab discipline).
|
|
184
|
+
* The WorkBuddyHostInstaller resolves its full path set by delegating here,
|
|
185
|
+
* so installer / status / health can never disagree about where the host
|
|
186
|
+
* files live.
|
|
187
|
+
*/
|
|
188
|
+
export function getWorkbuddyHostConfigPaths(homeDir, configDirOverride) {
|
|
189
|
+
const configDir = configDirOverride !== undefined && configDirOverride.length > 0
|
|
190
|
+
? path.resolve(configDirOverride)
|
|
191
|
+
: path.dirname(getWorkbuddyWorkspaceDir(homeDir));
|
|
192
|
+
return {
|
|
193
|
+
configDir,
|
|
194
|
+
settingsPath: path.join(configDir, 'settings.json'),
|
|
195
|
+
registryPath: path.join(configDir, 'plugins', 'installed_plugins.json'),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** rc-1 minimal guard: a plain JSON object, not an array/null/primitive. */
|
|
199
|
+
function isPlainJsonObject(value) {
|
|
200
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The shared plugin-state judgment (rc-2: no `as` bypass; rc-4/5). The exact
|
|
204
|
+
* semantics the installer has applied since PR #2355, extracted so pd-cli
|
|
205
|
+
* health reports the SAME three facts from the same rules:
|
|
206
|
+
* - registered: registry readable AND carried a plugins mapping with our key;
|
|
207
|
+
* - registryReadable: false only when the registry could not be read/parsed;
|
|
208
|
+
* - enabled: the boolean in settings.enabledPlugins[our key], or null when
|
|
209
|
+
* settings are unreadable, the key is absent, or the value is not boolean.
|
|
210
|
+
*/
|
|
211
|
+
export function interpretWorkbuddyPluginState(input) {
|
|
212
|
+
const registry = isPlainJsonObject(input.registryParsed) ? input.registryParsed : undefined;
|
|
213
|
+
const plugins = registry !== undefined && isPlainJsonObject(registry.plugins) ? registry.plugins : undefined;
|
|
214
|
+
const registered = input.registryReadable && plugins !== undefined
|
|
215
|
+
? Object.hasOwn(plugins, WORKBUDDY_PLUGIN_KEY)
|
|
216
|
+
: false;
|
|
217
|
+
const settings = isPlainJsonObject(input.settingsParsed) ? input.settingsParsed : undefined;
|
|
218
|
+
const enabledPlugins = settings !== undefined && isPlainJsonObject(settings.enabledPlugins) ? settings.enabledPlugins : undefined;
|
|
219
|
+
const raw = enabledPlugins === undefined ? undefined : enabledPlugins[WORKBUDDY_PLUGIN_KEY];
|
|
220
|
+
return {
|
|
221
|
+
registered,
|
|
222
|
+
registryReadable: input.registryReadable,
|
|
223
|
+
enabled: typeof raw === 'boolean' ? raw : null,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
167
226
|
export function resolveInstallLayout(options) {
|
|
168
227
|
const paths = getInstallLayoutPaths(options.homeDir);
|
|
169
228
|
const parsed = parseInstallManifest(options.manifest);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-principles-disciple",
|
|
3
|
-
"version": "1.147.
|
|
3
|
+
"version": "1.147.19",
|
|
4
4
|
"description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@earendil-works/pi-agent-core": "1.2.0",
|
|
65
65
|
"@earendil-works/pi-ai": "1.4.0",
|
|
66
|
-
"@principles/install-layout": "^0.
|
|
66
|
+
"@principles/install-layout": "^0.5.0",
|
|
67
67
|
"@sinclair/typebox": "^0.34.52",
|
|
68
68
|
"@tufjs/models": "3.0.1",
|
|
69
69
|
"@inquirer/prompts": "^8.7.2",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"directory": "packages/create-principles-disciple"
|
|
100
100
|
},
|
|
101
101
|
"pd": {
|
|
102
|
-
"bundledPluginVersion": "3.0.
|
|
102
|
+
"bundledPluginVersion": "3.0.2"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "e501b96540b127d14b8f5562c7ba1d3ed8bb9788"
|
|
105
105
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type WorkbuddyPluginStateView } from '@principles/install-layout';
|
|
2
|
+
export type WorkbuddyGovernanceState = 'ENABLED' | 'EXPLICITLY_DISABLED' | 'DEFAULT_OFF' | 'UNKNOWN';
|
|
3
|
+
export interface WorkbuddyHostFacts {
|
|
4
|
+
/** Registry + enablement, interpreted by the shared install-layout judgment. */
|
|
5
|
+
plugin: WorkbuddyPluginStateView;
|
|
6
|
+
governance: {
|
|
7
|
+
state: WorkbuddyGovernanceState;
|
|
8
|
+
/** The governance config file the flag was read from (null when absent/unreadable). */
|
|
9
|
+
configPath: string | null;
|
|
10
|
+
/** Structured reason when state === 'UNKNOWN' (rc-9). */
|
|
11
|
+
reason?: string;
|
|
12
|
+
};
|
|
13
|
+
/** Honest runtime boundary: static health never implies a live host. */
|
|
14
|
+
runtime: {
|
|
15
|
+
/** Always false — pd health never spawns WorkBuddy or the MCP server. */
|
|
16
|
+
probePerformed: false;
|
|
17
|
+
reason: string;
|
|
18
|
+
modelToolCall: 'NOT_VERIFIED';
|
|
19
|
+
};
|
|
20
|
+
paths: {
|
|
21
|
+
registryPath: string;
|
|
22
|
+
settingsPath: string;
|
|
23
|
+
governanceDir: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare function assessWorkbuddyHostFacts(options?: {
|
|
27
|
+
homeDir?: string;
|
|
28
|
+
configDirOverride?: string;
|
|
29
|
+
}): WorkbuddyHostFacts;
|
|
30
|
+
export declare function formatWorkbuddyHostFactLines(facts: WorkbuddyHostFacts): string[];
|
|
31
|
+
//# sourceMappingURL=health-workbuddy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-workbuddy.d.ts","sourceRoot":"","sources":["../../src/commands/health-workbuddy.ts"],"names":[],"mappings":"AAgCA,OAAO,EAIL,KAAK,wBAAwB,EAC9B,MAAM,4BAA4B,CAAC;AAIpC,MAAM,MAAM,wBAAwB,GAAG,SAAS,GAAG,qBAAqB,GAAG,aAAa,GAAG,SAAS,CAAC;AAErG,MAAM,WAAW,kBAAkB;IACjC,gFAAgF;IAChF,MAAM,EAAE,wBAAwB,CAAC;IACjC,UAAU,EAAE;QACV,KAAK,EAAE,wBAAwB,CAAC;QAChC,uFAAuF;QACvF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,yDAAyD;QACzD,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,wEAAwE;IACxE,OAAO,EAAE;QACP,yEAAyE;QACzE,cAAc,EAAE,KAAK,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,cAAc,CAAC;KAC/B,CAAC;IACF,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAkDD,wBAAgB,wBAAwB,CAAC,OAAO,GAAE;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,kBAAkB,CA8E1B;AASD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAehF"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkBuddy host-fact diagnostics for `pd health --host workbuddy`
|
|
3
|
+
* (2026-11-07, install ≠ enable ≠ governance ≠ MCP ≠ runtime).
|
|
4
|
+
*
|
|
5
|
+
* Read-only. It separates FOUR independent facts and never infers one from
|
|
6
|
+
* another (SPEC §6.4):
|
|
7
|
+
* 1. plugin registration — WorkBuddy installed_plugins.json (the host
|
|
8
|
+
* registry), via the SHARED install-layout interpreter (same judgment
|
|
9
|
+
* as the installer summary / `status`);
|
|
10
|
+
* 2. plugin enablement — settings.json enabledPlugins[key], tri-state;
|
|
11
|
+
* an unreadable settings file is UNKNOWN, never DISABLED;
|
|
12
|
+
* 3. governance — the PD feature flag `host.workbuddy` read from
|
|
13
|
+
* the governance workspace config the same way the production worker
|
|
14
|
+
* reads it (loadPdConfigForPlugin + computeFeatureFlagsFromConfig);
|
|
15
|
+
* an explicit Owner opt-out is reported as EXPLICITLY_DISABLED, never
|
|
16
|
+
* silently folded into a generic OFF;
|
|
17
|
+
* 4. MCP static config — the existing assessMcpHealth() section is the
|
|
18
|
+
* single authority for payload/binding/entry/pin/host-config/workspace
|
|
19
|
+
* integrity (unchanged); a present `pd-recall` MCP entry proves nothing
|
|
20
|
+
* about plugin registration or enablement.
|
|
21
|
+
*
|
|
22
|
+
* Runtime truthfulness (no probe): this module NEVER starts WorkBuddy, the
|
|
23
|
+
* MCP server, or any tool call. `pd health` stays read-only:
|
|
24
|
+
* - MCP static config correct ≠ plugin enabled ≠ real host runtime OK
|
|
25
|
+
* ≠ model actually invoked a PD tool.
|
|
26
|
+
* The facts carry probe.performed=false and modelToolCall=NOT_VERIFIED
|
|
27
|
+
* explicitly instead of implying health from static evidence.
|
|
28
|
+
*/
|
|
29
|
+
import * as fs from 'fs';
|
|
30
|
+
import * as os from 'os';
|
|
31
|
+
import * as path from 'path';
|
|
32
|
+
import * as yaml from 'js-yaml';
|
|
33
|
+
import { getWorkbuddyHostConfigPaths, getWorkbuddyWorkspaceDir, interpretWorkbuddyPluginState, } from '@principles/install-layout';
|
|
34
|
+
import { loadPdConfigForPlugin } from '@principles/host-runtime';
|
|
35
|
+
import { computeFeatureFlagsFromConfig } from '@principles/core/runtime';
|
|
36
|
+
function isPlainJsonObject(value) {
|
|
37
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The RAW user `features:` section of the governance config (rc-1: parsed as
|
|
41
|
+
* unknown, validated). The merged effective config fabricates default entries
|
|
42
|
+
* for every registered flag, so provenance ("did the Owner write this key?")
|
|
43
|
+
* can only come from this raw read. Returns undefined when the file cannot be
|
|
44
|
+
* read/parsed into an object with a features mapping.
|
|
45
|
+
*/
|
|
46
|
+
function readRawFeaturesSection(configPath) {
|
|
47
|
+
let raw;
|
|
48
|
+
try {
|
|
49
|
+
raw = fs.readFileSync(configPath, 'utf8');
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = yaml.load(raw, { schema: yaml.JSON_SCHEMA });
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
if (!isPlainJsonObject(parsed))
|
|
62
|
+
return undefined;
|
|
63
|
+
const features = isPlainJsonObject(parsed.features) ? parsed.features : undefined;
|
|
64
|
+
return features;
|
|
65
|
+
}
|
|
66
|
+
/** Read + parse a JSON host file. Returns { ok:false } when unreadable/unparsable/non-object. */
|
|
67
|
+
function readJsonHostFile(filePath) {
|
|
68
|
+
let raw;
|
|
69
|
+
try {
|
|
70
|
+
raw = fs.readFileSync(filePath, 'utf8');
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
const { code } = error;
|
|
74
|
+
if (code === 'ENOENT')
|
|
75
|
+
return { ok: true, value: undefined };
|
|
76
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const parsed = JSON.parse(raw);
|
|
80
|
+
if (!isPlainJsonObject(parsed))
|
|
81
|
+
return { ok: false, reason: 'not a JSON object' };
|
|
82
|
+
return { ok: true, value: parsed };
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function assessWorkbuddyHostFacts(options = {}) {
|
|
89
|
+
const homeDir = options.homeDir ?? os.homedir();
|
|
90
|
+
// Same override the installer honors (WORKBUDDY_CONFIG_DIR, Phase 0 lab
|
|
91
|
+
// discipline) — health must resolve the SAME registration root, never a
|
|
92
|
+
// second path authority.
|
|
93
|
+
const configDirOverride = options.configDirOverride ?? (process.env.WORKBUDDY_CONFIG_DIR !== undefined && process.env.WORKBUDDY_CONFIG_DIR.length > 0 ? process.env.WORKBUDDY_CONFIG_DIR : undefined);
|
|
94
|
+
const hostPaths = getWorkbuddyHostConfigPaths(homeDir, configDirOverride);
|
|
95
|
+
const governanceDir = getWorkbuddyWorkspaceDir(homeDir);
|
|
96
|
+
// Facts 1 + 2 — shared interpretation (rc-1: parsed values stay unknown
|
|
97
|
+
// until the interpreter validates them).
|
|
98
|
+
const registry = readJsonHostFile(hostPaths.registryPath);
|
|
99
|
+
const settings = readJsonHostFile(hostPaths.settingsPath);
|
|
100
|
+
const plugin = interpretWorkbuddyPluginState({
|
|
101
|
+
registryParsed: registry.ok ? registry.value : undefined,
|
|
102
|
+
settingsParsed: settings.ok ? settings.value : undefined,
|
|
103
|
+
registryReadable: registry.ok,
|
|
104
|
+
});
|
|
105
|
+
// Fact 3 — governance flag read the SAME way the production worker reads it.
|
|
106
|
+
const governanceConfigPath = path.join(governanceDir, '.pd', 'config.yaml');
|
|
107
|
+
let governance;
|
|
108
|
+
if (!fs.existsSync(governanceConfigPath)) {
|
|
109
|
+
governance = { state: 'UNKNOWN', configPath: null, reason: 'governance workspace config absent (workspace not initialized?)' };
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const loaded = loadPdConfigForPlugin(governanceDir);
|
|
113
|
+
if (!loaded.ok || loaded.source === 'malformed') {
|
|
114
|
+
governance = {
|
|
115
|
+
state: 'UNKNOWN',
|
|
116
|
+
configPath: governanceConfigPath,
|
|
117
|
+
reason: loaded.errors[0]?.reason ?? 'the governance config could not be read/parsed',
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const flag = computeFeatureFlagsFromConfig(loaded.effective).flags['host.workbuddy'];
|
|
122
|
+
// Explicit-vs-default distinction reads the RAW USER config — the
|
|
123
|
+
// merged effective config fabricates a default entry for EVERY
|
|
124
|
+
// registered flag (computeEffectivePdConfig), so key presence there
|
|
125
|
+
// proves nothing about authorship. This is the one deliberate second
|
|
126
|
+
// YAML read: provenance can only come from the file the Owner wrote.
|
|
127
|
+
const rawFeatures = readRawFeaturesSection(governanceConfigPath);
|
|
128
|
+
if (rawFeatures === undefined) {
|
|
129
|
+
governance = {
|
|
130
|
+
state: 'UNKNOWN',
|
|
131
|
+
configPath: governanceConfigPath,
|
|
132
|
+
reason: 'the governance config could not be re-read for provenance',
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const explicitEntry = Object.hasOwn(rawFeatures, 'host.workbuddy') ? rawFeatures['host.workbuddy'] : undefined;
|
|
137
|
+
const explicitOff = explicitEntry !== undefined && isPlainJsonObject(explicitEntry) && explicitEntry.enabled === false;
|
|
138
|
+
if (flag === undefined) {
|
|
139
|
+
governance = { state: 'UNKNOWN', configPath: governanceConfigPath, reason: 'host.workbuddy flag missing from the effective flag set' };
|
|
140
|
+
}
|
|
141
|
+
else if (flag.enabled === true) {
|
|
142
|
+
governance = { state: 'ENABLED', configPath: governanceConfigPath };
|
|
143
|
+
}
|
|
144
|
+
else if (explicitOff) {
|
|
145
|
+
// The Owner's config explicitly disables the flag — reported as its
|
|
146
|
+
// own state, never folded into a generic OFF.
|
|
147
|
+
governance = { state: 'EXPLICITLY_DISABLED', configPath: governanceConfigPath };
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
governance = { state: 'DEFAULT_OFF', configPath: governanceConfigPath };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
plugin,
|
|
157
|
+
governance,
|
|
158
|
+
runtime: {
|
|
159
|
+
probePerformed: false,
|
|
160
|
+
reason: 'pd health is read-only: it never starts WorkBuddy or the MCP server, so real runtime health is not probed.',
|
|
161
|
+
modelToolCall: 'NOT_VERIFIED',
|
|
162
|
+
},
|
|
163
|
+
paths: {
|
|
164
|
+
registryPath: hostPaths.registryPath,
|
|
165
|
+
settingsPath: hostPaths.settingsPath,
|
|
166
|
+
governanceDir,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
const LABELS = {
|
|
171
|
+
ENABLED: 'ENABLED',
|
|
172
|
+
EXPLICITLY_DISABLED: 'EXPLICITLY_DISABLED (your explicit opt-out was preserved)',
|
|
173
|
+
DEFAULT_OFF: 'DEFAULT_OFF (registry default — the config does not set the flag)',
|
|
174
|
+
UNKNOWN: 'UNKNOWN (config unreadable)',
|
|
175
|
+
};
|
|
176
|
+
export function formatWorkbuddyHostFactLines(facts) {
|
|
177
|
+
const lines = [];
|
|
178
|
+
lines.push('workbuddyPlugin:');
|
|
179
|
+
lines.push(` registration: ${facts.plugin.registryReadable ? (facts.plugin.registered ? 'REGISTERED' : 'NOT_REGISTERED') : 'UNKNOWN / REGISTRY UNREADABLE'}`);
|
|
180
|
+
lines.push(` enabled: ${facts.plugin.enabled === true ? 'ENABLED' : facts.plugin.enabled === false ? 'DISABLED' : 'UNKNOWN'}`);
|
|
181
|
+
lines.push(` governance: ${LABELS[facts.governance.state]}`);
|
|
182
|
+
if (facts.governance.reason !== undefined) {
|
|
183
|
+
lines.push(` governance.reason: ${facts.governance.reason}`);
|
|
184
|
+
}
|
|
185
|
+
lines.push(' runtime: RUNTIME_PROBE_NOT_PERFORMED (read-only health)');
|
|
186
|
+
lines.push(' modelToolCall: MODEL_TOOL_CALL_NOT_VERIFIED');
|
|
187
|
+
lines.push(` registryPath: ${facts.paths.registryPath}`);
|
|
188
|
+
lines.push(` settingsPath: ${facts.paths.settingsPath}`);
|
|
189
|
+
lines.push(` governanceDir: ${facts.paths.governanceDir}`);
|
|
190
|
+
return lines;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=health-workbuddy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-workbuddy.js","sourceRoot":"","sources":["../../src/commands/health-workbuddy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,E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C,KAAK,CAAC,IAAI,CAAC,wBAAwB,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;IACxE,KAAK,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;IAC5D,KAAK,CAAC,IAAI,CAAC,mBAAmB,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1D,KAAK,CAAC,IAAI,CAAC,mBAAmB,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1D,KAAK,CAAC,IAAI,CAAC,oBAAoB,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC;IAC5D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/commands/health.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/commands/health.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAsKtD,UAAU,aAAa;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,oFAAoF;IACpF,IAAI,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACjC;AAoBD,wBAAsB,YAAY,CAAC,IAAI,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoK1E;AAED;;;;GAIG;AACH,UAAU,qBAAqB;IAC7B,MAAM,CAAC,EAAE,OAAO,YAAY,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,iBAAiB,CAAC;CACxC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,GAAE,qBAA0B,GAAG,IAAI,CAkClG"}
|
|
@@ -16,6 +16,7 @@ import { getLedgerFilePathPublic } from '@principles/core/principle-tree-ledger'
|
|
|
16
16
|
import { createEvaluatorRuntimeContext, loadHostToolDeclarations, resolveWorkspaceHostToolSemantics, } from '@principles/host-runtime';
|
|
17
17
|
import { handleHealthCodex } from './health-codex.js';
|
|
18
18
|
import { assessMcpHealth, formatMcpHealthLines } from './health-mcp.js';
|
|
19
|
+
import { assessWorkbuddyHostFacts, formatWorkbuddyHostFactLines } from './health-workbuddy.js';
|
|
19
20
|
/**
|
|
20
21
|
* MCP statuses that describe an absent host rather than a broken one. Every
|
|
21
22
|
* other non-HEALTHY status is a real install/config defect and must fail
|
|
@@ -134,6 +135,9 @@ export async function handleHealth(opts = {}) {
|
|
|
134
135
|
const { missingLedgerCount } = await auditCandidateLedgerConsistency(workspaceDir);
|
|
135
136
|
const reliability = assessReliability(workspaceDir);
|
|
136
137
|
const mcp = assessMcpHealth({ host: opts.host === 'workbuddy' ? 'workbuddy' : 'openclaw' });
|
|
138
|
+
// 2026-11-07: the four host facts ride along ONLY for the workbuddy host —
|
|
139
|
+
// they are WorkBuddy-specific truths, never an openclaw/codex section.
|
|
140
|
+
const workbuddyHostFacts = opts.host === 'workbuddy' ? assessWorkbuddyHostFacts() : undefined;
|
|
137
141
|
let candidatesTotal = 0, candidatesConsumed = 0, candidatesPending = 0;
|
|
138
142
|
let tasksTotal = 0;
|
|
139
143
|
const tasksByStatus = {};
|
|
@@ -162,6 +166,7 @@ export async function handleHealth(opts = {}) {
|
|
|
162
166
|
mcp,
|
|
163
167
|
reuseEvaluation: assessReuseEvaluationTelemetry(workspaceDir),
|
|
164
168
|
lastSuccessfulChain,
|
|
169
|
+
...(workbuddyHostFacts !== undefined ? { workbuddyHostFacts } : {}),
|
|
165
170
|
};
|
|
166
171
|
}
|
|
167
172
|
function writeHealth() {
|
|
@@ -199,6 +204,13 @@ export async function handleHealth(opts = {}) {
|
|
|
199
204
|
}
|
|
200
205
|
for (const line of formatMcpHealthLines(health.mcp))
|
|
201
206
|
console.log(line);
|
|
207
|
+
// 2026-11-07: the four independent WorkBuddy facts — printed AFTER the
|
|
208
|
+
// MCP block so a full MCP section visibly does NOT imply a registered or
|
|
209
|
+
// enabled plugin (install ≠ enable ≠ governance ≠ MCP ≠ runtime).
|
|
210
|
+
if (health.workbuddyHostFacts !== undefined) {
|
|
211
|
+
for (const line of formatWorkbuddyHostFactLines(health.workbuddyHostFacts))
|
|
212
|
+
console.log(line);
|
|
213
|
+
}
|
|
202
214
|
console.log(`reuseEvaluation.criticalEventsFile: ${health.reuseEvaluation.criticalEventsFile}`);
|
|
203
215
|
if (health.reuseEvaluation.lastUnavailable) {
|
|
204
216
|
console.log('reuseEvaluation.lastUnavailable:');
|