create-principles-disciple 1.151.0 → 1.152.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.
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/tool-semantics.d.ts +11 -1
- package/codex-adapter/dist/tool-semantics.js +11 -1
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/index.js +5 -0
- package/console/dist/server/models/EvidenceChainConsoleModel.js +1 -2
- package/console/dist/server/models/GovernanceConsoleModel.js +56 -68
- package/console/dist/server/models/RuleCandidateBindingConsoleModel.js +31 -31
- package/console/dist/server/routes/failed-tasks.js +84 -1
- package/console/dist/server/routes/update.js +45 -30
- package/console/dist/server/update-timeout.js +15 -1
- package/console/dist/shared/rule-candidate-binding-contract.d.ts +4 -1
- package/console/dist/web/assets/app.js +26 -26
- package/core/dist/runtime/activation/ledger-identity.d.ts.map +1 -1
- package/core/dist/runtime/activation/ledger-identity.js +5 -0
- package/core/dist/runtime/activation/ledger-identity.js.map +1 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts +6 -0
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts.map +1 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.js +105 -7
- package/core/dist/runtime/activation/prompt-activation-reader-contract.js.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js +10 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js.map +1 -1
- package/core/dist/runtime/candidate-audit.d.ts.map +1 -1
- package/core/dist/runtime/candidate-audit.js +6 -3
- package/core/dist/runtime/candidate-audit.js.map +1 -1
- package/core/dist/runtime/golden-trace.d.ts.map +1 -1
- package/core/dist/runtime/golden-trace.js +30 -24
- package/core/dist/runtime/golden-trace.js.map +1 -1
- package/core/dist/runtime/internalization/refiner-sandbox-wrapper.d.ts.map +1 -1
- package/core/dist/runtime/internalization/refiner-sandbox-wrapper.js +4 -4
- package/core/dist/runtime/internalization/refiner-sandbox-wrapper.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +13 -0
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js +28 -4
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/rule-host-input-builder.d.ts +21 -1
- package/core/dist/runtime/internalization/rule-host-input-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-host-input-builder.js +13 -0
- package/core/dist/runtime/internalization/rule-host-input-builder.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.js +25 -3
- package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime/internalization-chain-integrity-read-model.d.ts +1 -0
- package/core/dist/runtime/internalization-chain-integrity-read-model.d.ts.map +1 -1
- package/core/dist/runtime/internalization-chain-integrity-read-model.js +8 -5
- package/core/dist/runtime/internalization-chain-integrity-read-model.js.map +1 -1
- package/core/dist/runtime/pruning-read-model.d.ts.map +1 -1
- package/core/dist/runtime/pruning-read-model.js +7 -5
- package/core/dist/runtime/pruning-read-model.js.map +1 -1
- package/core/dist/runtime/schema-conformance-read-model.d.ts +1 -0
- package/core/dist/runtime/schema-conformance-read-model.d.ts.map +1 -1
- package/core/dist/runtime/schema-conformance-read-model.js +8 -5
- package/core/dist/runtime/schema-conformance-read-model.js.map +1 -1
- package/core/dist/runtime/signal-collector/types.d.ts +6 -0
- package/core/dist/runtime/signal-collector/types.d.ts.map +1 -1
- package/core/dist/runtime/signal-collector/types.js.map +1 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts +1 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
- package/core/dist/trajectory-store.d.ts +17 -1
- package/core/dist/trajectory-store.d.ts.map +1 -1
- package/core/dist/trajectory-store.js +32 -10
- package/core/dist/trajectory-store.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +53 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +106 -1
- package/dist/installer.js.map +1 -1
- package/dist/installers/index.d.ts +31 -0
- package/dist/installers/index.d.ts.map +1 -1
- package/dist/installers/index.js +76 -3
- package/dist/installers/index.js.map +1 -1
- package/dist/installers/legacy-workbuddy-skill.d.ts +46 -14
- package/dist/installers/legacy-workbuddy-skill.d.ts.map +1 -1
- package/dist/installers/legacy-workbuddy-skill.js +162 -29
- package/dist/installers/legacy-workbuddy-skill.js.map +1 -1
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +7 -6
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/dist/update/release-manager.d.ts +1 -1
- package/dist/update/release-manager.d.ts.map +1 -1
- package/dist/update/release-manager.js +45 -2
- package/dist/update/release-manager.js.map +1 -1
- package/host-runtime/dist/active-principle-prompt.js +3 -2
- package/host-runtime/dist/governance-observation-store.js +2 -2
- package/host-runtime/dist/governance-signal-admission.js +14 -1
- package/host-runtime/dist/host-liveness-contract.js +2 -2
- package/host-runtime/dist/product-telemetry/milestone-readers.js +3 -2
- package/host-runtime/dist/production-pain-evidence.js +3 -2
- package/host-runtime/dist/production-rulehost-gate.d.ts +20 -0
- package/host-runtime/dist/production-rulehost-gate.js +110 -35
- package/host-runtime/dist/prompt-activation-deliverability.d.ts +2 -0
- package/host-runtime/dist/prompt-activation-deliverability.js +5 -3
- package/host-runtime/dist/prompt-injection-status.js +3 -2
- package/host-runtime/dist/workspace-behavior-evidence.js +4 -3
- package/host-runtime/package.json +5 -1
- package/install-layout/dist/mcp-binding-contract.js +5 -0
- package/install-layout/package.json +1 -1
- package/package.json +3 -3
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +2 -1
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +8 -0
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/demo-story-a.d.ts.map +1 -1
- package/pd-cli/dist/commands/demo-story-a.js +2 -1
- package/pd-cli/dist/commands/demo-story-a.js.map +1 -1
- package/pd-cli/dist/commands/health-mcp.d.ts +21 -0
- package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-mcp.js +19 -1
- package/pd-cli/dist/commands/health-mcp.js.map +1 -1
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +12 -4
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/legacy-cleanup.d.ts.map +1 -1
- package/pd-cli/dist/commands/legacy-cleanup.js +2 -1
- package/pd-cli/dist/commands/legacy-cleanup.js.map +1 -1
- package/pd-cli/dist/commands/pain-list.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-list.js +2 -1
- package/pd-cli/dist/commands/pain-list.js.map +1 -1
- package/pd-cli/dist/commands/principles-stats.d.ts.map +1 -1
- package/pd-cli/dist/commands/principles-stats.js +2 -1
- package/pd-cli/dist/commands/principles-stats.js.map +1 -1
- package/pd-cli/dist/commands/quality-scorecard.d.ts.map +1 -1
- package/pd-cli/dist/commands/quality-scorecard.js +2 -1
- package/pd-cli/dist/commands/quality-scorecard.js.map +1 -1
- package/pd-cli/dist/commands/runtime-init.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-init.js +5 -4
- package/pd-cli/dist/commands/runtime-init.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-evidence.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-evidence.js +2 -1
- package/pd-cli/dist/commands/runtime-internalization-evidence.js.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-task.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-task.js +2 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-task.js.map +1 -1
- package/pd-cli/dist/legacy/session-history-import.js +2 -2
- package/pd-cli/dist/legacy/session-history-import.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +15 -0
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +7 -1
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/pd-mcp-server/dist/index.js +33 -2
- package/pd-mcp-server/dist/server.d.ts +7 -3
- package/pd-mcp-server/dist/server.js +6 -1
- package/pd-mcp-server/dist/submit-assembly.d.ts +24 -0
- package/pd-mcp-server/dist/submit-assembly.js +61 -0
- package/pd-mcp-server/dist/version.d.ts +1 -1
- package/pd-mcp-server/dist/version.js +1 -1
- package/pd-mcp-server/package.json +2 -1
- package/plugin/dist/bundle.js +451 -473
- package/plugin/dist/constants/tool-semantics.d.ts +13 -0
- package/plugin/dist/core/correction-anchor.d.ts +40 -0
- package/plugin/dist/core/experiment-workspace-guard.d.ts +10 -0
- package/plugin/dist/core/mcp-binding.d.ts +3 -1
- package/plugin/dist/core/signal-collector-host.d.ts +19 -1
- package/plugin/dist/core/workspace-context.d.ts +0 -4
- package/plugin/dist/hooks/gate.d.ts +0 -5
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +4 -4
- package/plugin/mcp/launcher.cjs +85 -0
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +106 -1
- package/release-manager/dist/installers/index.js +76 -3
- package/release-manager/dist/installers/legacy-workbuddy-skill.js +162 -29
- package/release-manager/dist/installers/workbuddy-host-installer.js +7 -6
- package/release-manager/dist/update/release-manager.js +45 -2
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/dist/tool-semantics.d.ts +11 -0
- package/workbuddy-adapter/dist/tool-semantics.js +11 -0
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/mcp/launcher.cjs +85 -0
- package/plugin/dist/core/rule-host.d.ts +0 -203
|
@@ -12,7 +12,7 @@ import { logger } from './utils/logger.js';
|
|
|
12
12
|
import { checkOpenClawGateway, stopOpenClawGateway, restartOpenClawGateway } from './utils/env.js';
|
|
13
13
|
import { t } from './i18n.js';
|
|
14
14
|
import { generateConfigYamlContent, ExistingConfigVerifyInfraError, validateExistingConfigYamlForPreserve, getConfigYamlPath, readEnabledChannelsFromConfigYaml, getOpenClawDir, getPdDir, getPdRuntimeDir, getInstallManifestPath, getPdRuntimeBackupsDir, getPluginExtDir, getInstalledPluginDir, getInstalledLayoutPackageDir, getPdBackupsDir, getInstalledPdCliDir, getInstalledBinDir, getInstalledConsoleDir, getHomeDir, isWindows, } from './mvp-config.js';
|
|
15
|
-
import { detectInstalledHosts, getHostInstallers } from './installers/index.js';
|
|
15
|
+
import { detectInstalledHosts, evaluateRecordedHostPresence, getHostInstallers, isRecordedHost } from './installers/index.js';
|
|
16
16
|
import { readCanonicalRuntimeCohort, readInstalledRuntimeCohort, resolvePluginDataRoot } from './installers/codex-host-installer.js';
|
|
17
17
|
import { runWorkbuddyEarlyPreflight } from './installers/workbuddy-host-installer.js';
|
|
18
18
|
import { INSTALL_LAYOUT_VERSION, getInstallLayoutPaths, getWorkbuddyWorkspaceDir, installManifestHostsForPersist, mergeInstallManifestWorkspaces, parseInstallManifest } from '@principles/install-layout';
|
|
@@ -610,6 +610,87 @@ export async function repairUpdateChain(input) {
|
|
|
610
610
|
notes,
|
|
611
611
|
};
|
|
612
612
|
}
|
|
613
|
+
export function repairInstallManifestHosts(options = {}) {
|
|
614
|
+
const manifestPath = getInstallManifestPath();
|
|
615
|
+
const refuse = (reason, nextAction) => ({
|
|
616
|
+
success: false,
|
|
617
|
+
applied: false,
|
|
618
|
+
manifestPath,
|
|
619
|
+
before: [],
|
|
620
|
+
after: [],
|
|
621
|
+
removed: [],
|
|
622
|
+
entries: [],
|
|
623
|
+
reason,
|
|
624
|
+
nextAction,
|
|
625
|
+
});
|
|
626
|
+
let raw;
|
|
627
|
+
try {
|
|
628
|
+
raw = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
629
|
+
}
|
|
630
|
+
catch (error) {
|
|
631
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
632
|
+
return refuse(`install_manifest_unreadable: ${detail}`, `Inspect ${manifestPath} and re-run the official installer once it is valid JSON.`);
|
|
633
|
+
}
|
|
634
|
+
const parsed = parseInstallManifest(raw);
|
|
635
|
+
if (parsed.manifest === undefined) {
|
|
636
|
+
return refuse(parsed.error ?? 'install_manifest_malformed', `Inspect ${manifestPath}; the host record cannot be judged safely.`);
|
|
637
|
+
}
|
|
638
|
+
const before = installManifestHostsForPersist(parsed.manifest);
|
|
639
|
+
const entries = before.map((host) => {
|
|
640
|
+
if (!isRecordedHost(host)) {
|
|
641
|
+
return { host, verdict: 'not-judged', detail: 'unknown host id — never removed by this repair' };
|
|
642
|
+
}
|
|
643
|
+
const presence = evaluateRecordedHostPresence(host, getHomeDir());
|
|
644
|
+
return presence.status === 'undecidable'
|
|
645
|
+
? { host, verdict: 'undecidable', detail: presence.reason }
|
|
646
|
+
: { host, verdict: presence.status, detail: presence.evidence };
|
|
647
|
+
});
|
|
648
|
+
const removed = entries.filter((entry) => entry.verdict === 'absent').map((entry) => entry.host);
|
|
649
|
+
const after = before.filter((host) => !removed.includes(host));
|
|
650
|
+
if (removed.length === 0) {
|
|
651
|
+
return {
|
|
652
|
+
success: true,
|
|
653
|
+
applied: false,
|
|
654
|
+
manifestPath,
|
|
655
|
+
before,
|
|
656
|
+
after,
|
|
657
|
+
removed,
|
|
658
|
+
entries,
|
|
659
|
+
nextAction: 'Nothing to repair: every recorded host is installed or cannot be judged safely.',
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
if (after.length === 0) {
|
|
663
|
+
return refuse('manifest_would_be_empty: every recorded host is provably absent, so no host installer would serve this installation', `Re-run the official installer to register a host before repairing ${manifestPath}.`);
|
|
664
|
+
}
|
|
665
|
+
if (options.apply !== true) {
|
|
666
|
+
return {
|
|
667
|
+
success: true,
|
|
668
|
+
applied: false,
|
|
669
|
+
manifestPath,
|
|
670
|
+
before,
|
|
671
|
+
after,
|
|
672
|
+
removed,
|
|
673
|
+
entries,
|
|
674
|
+
nextAction: 'Dry run — re-run with --apply to write the repair (the current file is backed up first).',
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
const backupPath = path.join(getPdRuntimeBackupsDir(), `install-manifest.backup.${Date.now()}.json`);
|
|
678
|
+
mkdirSync(getPdRuntimeBackupsDir(), { recursive: true });
|
|
679
|
+
writeFileSync(backupPath, readFileSync(manifestPath));
|
|
680
|
+
writeInstallManifest([...after], [...(parsed.manifest.workspaces ?? [])]);
|
|
681
|
+
return {
|
|
682
|
+
success: true,
|
|
683
|
+
applied: true,
|
|
684
|
+
manifestPath,
|
|
685
|
+
before,
|
|
686
|
+
after,
|
|
687
|
+
removed,
|
|
688
|
+
entries,
|
|
689
|
+
backupPath,
|
|
690
|
+
restoreCommand: `cp "${backupPath}" "${manifestPath}"`,
|
|
691
|
+
nextAction: `Removed ${removed.join(', ')} from the host record. Restore the previous value with: cp "${backupPath}" "${manifestPath}"`,
|
|
692
|
+
};
|
|
693
|
+
}
|
|
613
694
|
function installBundledLayoutPackage(pluginDir) {
|
|
614
695
|
const source = path.join(pluginDir, 'install-layout');
|
|
615
696
|
const destination = getInstalledLayoutPackageDir();
|
|
@@ -2744,6 +2825,26 @@ export function ensureCodexAdapterResolution() {
|
|
|
2744
2825
|
export function ensureHostRuntimeResolution() {
|
|
2745
2826
|
ensureComponentFileDependencyLinks(getInstalledHostRuntimeDir(), '@principles/host-runtime');
|
|
2746
2827
|
}
|
|
2828
|
+
/**
|
|
2829
|
+
* PRI-1201: the INSTALLED release-manager component declares the same
|
|
2830
|
+
* `file:../<component>` sibling contract as every other runtime component
|
|
2831
|
+
* (@principles/install-layout), but — exactly like host-runtime before
|
|
2832
|
+
* PRI-1145 — it had no `ensure*Resolution()` caller. `installBundledReleaseManagerPackage`
|
|
2833
|
+
* + `installReleaseManagerDependencies` (and the self-contained payload's
|
|
2834
|
+
* build-time npm ci) therefore left a physical `node_modules/@principles/
|
|
2835
|
+
* install-layout` copy behind: a second install-layout byte that never
|
|
2836
|
+
* refreshes with the canonical sibling. Reuses the shared helper
|
|
2837
|
+
* (Connection Before Creation) instead of a new mechanism.
|
|
2838
|
+
*
|
|
2839
|
+
* Ordering contract: MUST run after installReleaseManagerDependencies() (that
|
|
2840
|
+
* stage is what can materialize node_modules) AND after installBundledLayoutPackage()
|
|
2841
|
+
* deployed the install-layout sibling. It also precedes
|
|
2842
|
+
* verifyReleaseManagerAuthorityImports() so the probe loads the module through
|
|
2843
|
+
* the canonical sibling. A missing sibling fails the install loud (the helper).
|
|
2844
|
+
*/
|
|
2845
|
+
export function ensureReleaseManagerResolution() {
|
|
2846
|
+
ensureComponentFileDependencyLinks(getInstalledReleaseManagerDir(), '@principles/release-manager');
|
|
2847
|
+
}
|
|
2747
2848
|
/**
|
|
2748
2849
|
* SPEC workbuddy-host-adapter §4.1/§5: the bundled @principles/workbuddy-adapter
|
|
2749
2850
|
* payload installs as a runtime sibling exactly like codex-adapter, and its
|
|
@@ -4288,6 +4389,10 @@ transaction) {
|
|
|
4288
4389
|
updateProgress(spinner, stepIndex, 'Installing release-manager authority module...');
|
|
4289
4390
|
installBundledReleaseManagerPackage(pluginDir);
|
|
4290
4391
|
await installReleaseManagerDependencies();
|
|
4392
|
+
// PRI-1201: install-layout is already deployed (installBundledLayoutPackage
|
|
4393
|
+
// above), so the dependency stage's physical copy is corrected before the
|
|
4394
|
+
// import probe loads the authority through its canonical sibling.
|
|
4395
|
+
ensureReleaseManagerResolution();
|
|
4291
4396
|
await verifyReleaseManagerAuthorityImports();
|
|
4292
4397
|
stepIndex++;
|
|
4293
4398
|
if (spinner)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as os from 'os';
|
|
4
4
|
import { OpenClawHostInstaller } from './openclaw-host-installer.js';
|
|
5
|
-
import { CodexHostInstaller } from './codex-host-installer.js';
|
|
6
|
-
import { WorkBuddyHostInstaller, readWorkbuddyHostState } from './workbuddy-host-installer.js';
|
|
5
|
+
import { CodexHostInstaller, detectCodexMarketplaceState } from './codex-host-installer.js';
|
|
6
|
+
import { WorkBuddyHostInstaller, readWorkbuddyHostState, resolveWorkbuddyPaths } from './workbuddy-host-installer.js';
|
|
7
7
|
export { OpenClawHostInstaller } from './openclaw-host-installer.js';
|
|
8
8
|
export { CodexHostInstaller } from './codex-host-installer.js';
|
|
9
9
|
export { WorkBuddyHostInstaller } from './workbuddy-host-installer.js';
|
|
@@ -78,4 +78,77 @@ export function detectInstalledHosts(homeDir = os.homedir(), codexHome) {
|
|
|
78
78
|
}
|
|
79
79
|
return detected;
|
|
80
80
|
}
|
|
81
|
+
export const RECORDED_HOSTS = ['openclaw', 'codex', 'workbuddy'];
|
|
82
|
+
export function isRecordedHost(value) {
|
|
83
|
+
return RECORDED_HOSTS.includes(value);
|
|
84
|
+
}
|
|
85
|
+
function errorCode(error) {
|
|
86
|
+
if (error instanceof Error && Object.hasOwn(error, 'code')) {
|
|
87
|
+
const code = Reflect.get(error, 'code');
|
|
88
|
+
return typeof code === 'string' ? code : undefined;
|
|
89
|
+
}
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
function describeError(error) {
|
|
93
|
+
return error instanceof Error ? error.message : String(error);
|
|
94
|
+
}
|
|
95
|
+
export function evaluateRecordedHostPresence(host, homeDir = os.homedir()) {
|
|
96
|
+
const detected = detectInstalledHosts(homeDir).find((entry) => entry.hostId === host);
|
|
97
|
+
if (detected !== undefined) {
|
|
98
|
+
return { status: 'installed', evidence: detected.evidence };
|
|
99
|
+
}
|
|
100
|
+
if (host === 'openclaw') {
|
|
101
|
+
const openclawDir = path.join(homeDir, '.openclaw');
|
|
102
|
+
const configPath = path.join(openclawDir, 'openclaw.json');
|
|
103
|
+
let raw;
|
|
104
|
+
try {
|
|
105
|
+
raw = readFileSync(configPath, 'utf8');
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (errorCode(error) === 'ENOENT') {
|
|
109
|
+
return { status: 'absent', evidence: `no PD extension and no ${configPath}` };
|
|
110
|
+
}
|
|
111
|
+
return { status: 'undecidable', reason: `cannot read ${configPath}: ${describeError(error)}` };
|
|
112
|
+
}
|
|
113
|
+
// Conservative: a config that still names PD counts as installed even when
|
|
114
|
+
// the extension directory is gone — dropping the record would strand those
|
|
115
|
+
// entries, and a false "installed" only keeps the manifest as it is.
|
|
116
|
+
if (raw.includes('principles-disciple')) {
|
|
117
|
+
return { status: 'installed', evidence: `${configPath} still references principles-disciple` };
|
|
118
|
+
}
|
|
119
|
+
return { status: 'absent', evidence: `no PD extension and ${configPath} does not reference principles-disciple` };
|
|
120
|
+
}
|
|
121
|
+
if (host === 'codex') {
|
|
122
|
+
const detection = new CodexHostInstaller().detect();
|
|
123
|
+
if (detection.installed) {
|
|
124
|
+
const evidence = detection.paths.find((entry) => entry.exists);
|
|
125
|
+
return { status: 'installed', evidence: evidence?.path ?? 'codex install detected' };
|
|
126
|
+
}
|
|
127
|
+
// The Marketplace cache is the supported install path: its three-state
|
|
128
|
+
// detector distinguishes "absent" from "cannot judge".
|
|
129
|
+
const marketplace = detectCodexMarketplaceState();
|
|
130
|
+
if (marketplace.state === 'unknown') {
|
|
131
|
+
return { status: 'undecidable', reason: marketplace.reason };
|
|
132
|
+
}
|
|
133
|
+
const hooks = detection.paths.find((entry) => entry.name === 'Codex hooks.json' && entry.exists);
|
|
134
|
+
if (hooks !== undefined) {
|
|
135
|
+
try {
|
|
136
|
+
JSON.parse(readFileSync(hooks.path, 'utf8'));
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
return { status: 'undecidable', reason: `${hooks.path} exists but cannot be read as JSON: ${describeError(error)}` };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { status: 'absent', evidence: 'no PD marker, PD hook entries, or Marketplace plugin in the Codex home' };
|
|
143
|
+
}
|
|
144
|
+
const workbuddyPaths = resolveWorkbuddyPaths(homeDir);
|
|
145
|
+
const workbuddy = readWorkbuddyHostState(homeDir);
|
|
146
|
+
if (workbuddy.pluginState === undefined) {
|
|
147
|
+
return { status: 'undecidable', reason: 'workbuddy plugin state could not be read' };
|
|
148
|
+
}
|
|
149
|
+
if (!workbuddy.pluginState.registryReadable) {
|
|
150
|
+
return { status: 'undecidable', reason: `${workbuddyPaths.registryPath} exists but is not a readable plugin registry` };
|
|
151
|
+
}
|
|
152
|
+
return { status: 'absent', evidence: `PD is not registered in ${workbuddyPaths.registryPath}` };
|
|
153
|
+
}
|
|
81
154
|
//# sourceMappingURL=index.js.map
|
|
@@ -2,15 +2,26 @@
|
|
|
2
2
|
* Legacy WorkBuddy user-level skill retirement
|
|
3
3
|
* (SPEC-PD-AGENT-PAIN-INGRESS-001 §5.5 / TECHNICAL-DESIGN §7.4).
|
|
4
4
|
*
|
|
5
|
-
* PD
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* PD no longer ships ANY user-level skill: the four active capabilities live
|
|
6
|
+
* inside the plugin payload, and pain raised by an agent is ingested through
|
|
7
|
+
* the governed host path. Older installs, however, left several retired
|
|
8
|
+
* skills behind in `~/.workbuddy/skills/`:
|
|
9
|
+
*
|
|
10
|
+
* - `pd-record-pain` — wrote pain through a retired, ungoverned channel;
|
|
11
|
+
* - `pd-status` / `pd-setup` / `pd-disable` — Codex-era skills that point
|
|
12
|
+
* at `~/.codex/plugins/cache/`, `host.codex` and Codex `/hooks`;
|
|
13
|
+
* - `pd-review` (pre-unification payload) — competes by directory name with
|
|
14
|
+
* the plugin's CURRENT `pd-review`, so the host may load the stale one.
|
|
15
|
+
*
|
|
16
|
+
* The last four were deleted/rewritten by 5c383e572 ("refactor(skills):
|
|
17
|
+
* unify PD host skill capabilities", 2026-10-22) but were never added to the
|
|
18
|
+
* retirement registry, so every later install/upgrade left them in place.
|
|
19
|
+
* This module now retires all of them under the same preservation-first rules.
|
|
9
20
|
*
|
|
10
21
|
* Rules this module implements — and the reasons each one exists:
|
|
11
22
|
*
|
|
12
23
|
* 1. Detection is path + frontmatter `name`. A directory that happens to be
|
|
13
|
-
* called
|
|
24
|
+
* called like a retired skill but declares a different name is the
|
|
14
25
|
* Owner's own skill; it is never touched and never reported.
|
|
15
26
|
* 2. Only a copy whose bytes match a PUBLISHED skill payload may be renamed.
|
|
16
27
|
* The published payload hashes below are derived from this repository's
|
|
@@ -27,25 +38,101 @@
|
|
|
27
38
|
import { createHash } from 'node:crypto';
|
|
28
39
|
import { existsSync, readdirSync, readFileSync, renameSync } from 'node:fs';
|
|
29
40
|
import * as path from 'node:path';
|
|
30
|
-
export const LEGACY_WORKBUDDY_SKILL_DIR = 'pd-record-pain';
|
|
31
41
|
export const LEGACY_WORKBUDDY_SKILL_FILE = 'SKILL.md';
|
|
32
42
|
/**
|
|
33
|
-
* Every
|
|
34
|
-
* recovered from git history (`git cat-file blob <blob>`).
|
|
35
|
-
*
|
|
43
|
+
* Every user-level PD skill payload this repository has ever shipped and
|
|
44
|
+
* later retired, recovered from git history (`git cat-file blob <blob>`).
|
|
45
|
+
*
|
|
46
|
+
* Only blobs published BEFORE 5c383e572 are listed for `pd-review`: the
|
|
47
|
+
* post-unification payloads are still shipped inside the plugin and must
|
|
48
|
+
* never be retired, even if an Owner copied one into the user-level dir.
|
|
36
49
|
*/
|
|
37
|
-
export const
|
|
50
|
+
export const LEGACY_WORKBUDDY_SKILL_ENTRIES = [
|
|
51
|
+
{
|
|
52
|
+
dir: 'pd-record-pain',
|
|
53
|
+
published: [
|
|
54
|
+
{
|
|
55
|
+
label: '0.1.1-openclaw',
|
|
56
|
+
sha256: 'beb758bd66c6e330ff18bb751136a276d98486d85876b4488d09551b672d8186',
|
|
57
|
+
provenance: 'plugins/principles-disciple/skills/pd-record-pain/SKILL.md @ plugin 0.1.1 (blob 7df4717)',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: '0.1.0-workbuddy',
|
|
61
|
+
sha256: 'f2eee21234250bf530a81579f033cda4fa41c0728bc81536320774127bd2d6e6',
|
|
62
|
+
provenance: 'packages/workbuddy-adapter/plugin/skills/pd-record-pain/SKILL.md @ plugin 0.1.0 (blob 7338fe8)',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
dir: 'pd-status',
|
|
68
|
+
published: [
|
|
69
|
+
{
|
|
70
|
+
label: 'codex-2026-09-23',
|
|
71
|
+
sha256: '853d5f8de9996239dbfc4d1fca27f5e96cd852cf1b8deea0c1cb8d1655800126',
|
|
72
|
+
provenance: 'plugins/principles-disciple/skills/pd-status/SKILL.md @ 42f0f4a7',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: 'workbuddy-2026-10-17',
|
|
76
|
+
sha256: '0b9b3bc6e730b4d9244522f9b9bc5a7ce27f29a82ec9ff432105ab21ae3573e0',
|
|
77
|
+
provenance: 'packages/workbuddy-adapter/plugin/skills/pd-status/SKILL.md @ b02ebb53',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
dir: 'pd-setup',
|
|
83
|
+
published: [
|
|
84
|
+
{
|
|
85
|
+
label: 'codex-2026-08-14',
|
|
86
|
+
sha256: 'bf4ad63c94a692c0264b357659a0b8db3acddcc26ac190f2a5dd81e04501b9ab',
|
|
87
|
+
provenance: 'plugins/principles-disciple/skills/pd-setup/SKILL.md @ 03747736',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: 'codex-2026-09-23',
|
|
91
|
+
sha256: 'fd1dbd26d0dc87e201a89bf2790cbe136a93921a62e45bca428037ef1ecf1bfa',
|
|
92
|
+
provenance: 'plugins/principles-disciple/skills/pd-setup/SKILL.md @ 42f0f4a7',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
label: 'codex-2026-10-05',
|
|
96
|
+
sha256: '8d6eae4df8b311c37e86788bc5487a5b692970573334f5b890ee6fd452f20502',
|
|
97
|
+
provenance: 'plugins/principles-disciple/skills/pd-setup/SKILL.md @ cee2304f',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
38
101
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
102
|
+
dir: 'pd-disable',
|
|
103
|
+
published: [
|
|
104
|
+
{
|
|
105
|
+
label: 'codex-2026-09-23',
|
|
106
|
+
sha256: '590769fcf93d60389346e001ce8a76c2157976f5d38035523f3807ffc2477f8e',
|
|
107
|
+
provenance: 'plugins/principles-disciple/skills/pd-disable/SKILL.md @ 42f0f4a7',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: 'workbuddy-2026-10-17',
|
|
111
|
+
sha256: '25172b5f67503c07cf31e06dc6092796fc277faad6f8746ce9595bf951294f86',
|
|
112
|
+
provenance: 'packages/workbuddy-adapter/plugin/skills/pd-disable/SKILL.md @ b02ebb53',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
42
115
|
},
|
|
43
116
|
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
117
|
+
dir: 'pd-review',
|
|
118
|
+
published: [
|
|
119
|
+
{
|
|
120
|
+
label: 'codex-2026-09-23',
|
|
121
|
+
sha256: '18665f1a8e0d5a34ab245859cc34f08c56c8946648274e870e95d1642e331b74',
|
|
122
|
+
provenance: 'plugins/principles-disciple/skills/pd-review/SKILL.md @ 42f0f4a7 (pre-unification)',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
label: 'workbuddy-2026-10-17',
|
|
126
|
+
sha256: '635fa9c7aa232cacd356bb25dc7e1c1c00305786fdcc930d03257edbeea0216e',
|
|
127
|
+
provenance: 'packages/workbuddy-adapter/plugin/skills/pd-review/SKILL.md @ b02ebb53 (pre-unification)',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
47
130
|
},
|
|
48
131
|
];
|
|
132
|
+
/** Kept for backwards compatibility with the single-skill callers/tests. */
|
|
133
|
+
export const LEGACY_WORKBUDDY_SKILL_DIR = 'pd-record-pain';
|
|
134
|
+
/** Kept for backwards compatibility: the `pd-record-pain` payloads. */
|
|
135
|
+
export const PUBLISHED_LEGACY_WORKBUDDY_SKILLS = LEGACY_WORKBUDDY_SKILL_ENTRIES.find((entry) => entry.dir === LEGACY_WORKBUDDY_SKILL_DIR)?.published ?? [];
|
|
49
136
|
function frontmatterName(content) {
|
|
50
137
|
// Minimal, format-only parse: the skill frontmatter is a leading `---` block
|
|
51
138
|
// of `key: value` lines. We only need `name`, and a missing block is a
|
|
@@ -66,18 +153,21 @@ function frontmatterName(content) {
|
|
|
66
153
|
function sha256Of(bytes) {
|
|
67
154
|
return createHash('sha256').update(bytes).digest('hex');
|
|
68
155
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
156
|
+
function publishedForSkill(dirName) {
|
|
157
|
+
return LEGACY_WORKBUDDY_SKILL_ENTRIES.find((entry) => entry.dir === dirName)?.published ?? [];
|
|
158
|
+
}
|
|
159
|
+
function skillDir(configDir, dirName) {
|
|
160
|
+
return path.join(configDir, 'skills', dirName);
|
|
71
161
|
}
|
|
72
162
|
/**
|
|
73
163
|
* Read-only inspection. Never renames, never deletes.
|
|
74
164
|
*
|
|
75
|
-
*
|
|
76
|
-
* fixture; production callers always use the shipped registry.
|
|
165
|
+
* Production callers always use the shipped registry for `skillDir`.
|
|
77
166
|
*/
|
|
78
167
|
export function inspectLegacyWorkbuddySkill(options) {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
168
|
+
const dirName = options.skillDir ?? LEGACY_WORKBUDDY_SKILL_DIR;
|
|
169
|
+
const publishedVersions = options.published ?? publishedForSkill(dirName);
|
|
170
|
+
const dir = skillDir(options.configDir, dirName);
|
|
81
171
|
const skillPath = path.join(dir, LEGACY_WORKBUDDY_SKILL_FILE);
|
|
82
172
|
if (!existsSync(skillPath)) {
|
|
83
173
|
// Idempotency: a previously retired copy leaves only the suffixed file.
|
|
@@ -93,7 +183,7 @@ export function inspectLegacyWorkbuddySkill(options) {
|
|
|
93
183
|
: { status: 'already_deprecated', path: skillPath, deprecatedPath };
|
|
94
184
|
}
|
|
95
185
|
const bytes = readFileSync(skillPath);
|
|
96
|
-
if (frontmatterName(bytes.toString('utf8')) !==
|
|
186
|
+
if (frontmatterName(bytes.toString('utf8')) !== dirName) {
|
|
97
187
|
// Same directory name, different declared skill: not ours to retire.
|
|
98
188
|
return { status: 'absent', path: skillPath };
|
|
99
189
|
}
|
|
@@ -116,17 +206,41 @@ export function inspectLegacyWorkbuddySkill(options) {
|
|
|
116
206
|
};
|
|
117
207
|
}
|
|
118
208
|
/**
|
|
119
|
-
* Retire
|
|
209
|
+
* Retire ONE legacy user-level skill when it is provably an unmodified PD
|
|
120
210
|
* payload. Safe to run on every install/upgrade: absent, already-retired and
|
|
121
211
|
* Owner-modified states are all no-ops.
|
|
122
212
|
*/
|
|
123
213
|
export function deprecateLegacyWorkbuddySkill(options) {
|
|
124
|
-
const
|
|
214
|
+
const dirName = options.skillDir ?? LEGACY_WORKBUDDY_SKILL_DIR;
|
|
215
|
+
// Retirement runs AFTER the installer has already committed the plugin
|
|
216
|
+
// registration and the config, so an inspection throw here would make a
|
|
217
|
+
// successful install report failure. One unreadable entry (EISDIR on a
|
|
218
|
+
// `SKILL.md` directory, EACCES/EISDIR on a locked file) is isolated into a
|
|
219
|
+
// warning and the caller keeps going — including the aggregate loop.
|
|
220
|
+
let state;
|
|
221
|
+
try {
|
|
222
|
+
state = inspectLegacyWorkbuddySkill({ ...options, skillDir: dirName });
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
226
|
+
return {
|
|
227
|
+
state: {
|
|
228
|
+
status: 'inspection_failed',
|
|
229
|
+
path: path.join(skillDir(options.configDir, dirName), LEGACY_WORKBUDDY_SKILL_FILE),
|
|
230
|
+
reason,
|
|
231
|
+
},
|
|
232
|
+
warnings: [
|
|
233
|
+
`WARNING [legacy_skill_inspection_failed]: the retired skill "${dirName}" could not be inspected (${reason}).`,
|
|
234
|
+
` It was left untouched; skill discovery may still load it. Fix permissions or delete the directory yourself.`,
|
|
235
|
+
],
|
|
236
|
+
};
|
|
237
|
+
}
|
|
125
238
|
if (state.status === 'modified') {
|
|
126
239
|
return {
|
|
127
240
|
state,
|
|
128
241
|
warnings: [
|
|
129
|
-
'WARNING [deprecated_skill_modified]: a retired user-level skill
|
|
242
|
+
'WARNING [deprecated_skill_modified]: a retired user-level skill ' +
|
|
243
|
+
`"${dirName}" was found but NOT modified ` +
|
|
130
244
|
`(${state.path}, sha256 ${state.sha256.slice(0, 12)}…) — its content matches no published version.`,
|
|
131
245
|
` ${state.nextAction}`,
|
|
132
246
|
],
|
|
@@ -142,7 +256,7 @@ export function deprecateLegacyWorkbuddySkill(options) {
|
|
|
142
256
|
return {
|
|
143
257
|
state,
|
|
144
258
|
warnings: [
|
|
145
|
-
`WARNING [legacy_skill_rename_failed]: retired skill "
|
|
259
|
+
`WARNING [legacy_skill_rename_failed]: retired skill "${dirName}" could not be renamed because ${state.deprecatedPath} already exists.`,
|
|
146
260
|
` Move or delete ${state.path} yourself; skill discovery still sees it.`,
|
|
147
261
|
],
|
|
148
262
|
};
|
|
@@ -153,7 +267,7 @@ export function deprecateLegacyWorkbuddySkill(options) {
|
|
|
153
267
|
return {
|
|
154
268
|
state,
|
|
155
269
|
warnings: [
|
|
156
|
-
`WARNING [legacy_skill_rename_failed]: retired skill "
|
|
270
|
+
`WARNING [legacy_skill_rename_failed]: retired skill "${dirName}" could not be renamed (${error instanceof Error ? error.message : String(error)}).`,
|
|
157
271
|
` Delete ${state.path} yourself; skill discovery still sees it.`,
|
|
158
272
|
],
|
|
159
273
|
};
|
|
@@ -161,8 +275,27 @@ export function deprecateLegacyWorkbuddySkill(options) {
|
|
|
161
275
|
return {
|
|
162
276
|
state,
|
|
163
277
|
warnings: [
|
|
164
|
-
`Retired the obsolete user-level skill "
|
|
278
|
+
`Retired the obsolete user-level skill "${dirName}" (renamed to ${path.basename(state.deprecatedPath)}).`,
|
|
165
279
|
],
|
|
166
280
|
};
|
|
167
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Retire EVERY registered legacy user-level skill. This is the production
|
|
284
|
+
* entry point for install/upgrade: one retired skill must not mask the others.
|
|
285
|
+
*
|
|
286
|
+
* `entries` is injectable so tests can exercise the loop without touching the
|
|
287
|
+
* shipped registry; production callers always use the registry.
|
|
288
|
+
*/
|
|
289
|
+
export function deprecateAllLegacyWorkbuddySkills(options) {
|
|
290
|
+
const entries = options.entries ?? LEGACY_WORKBUDDY_SKILL_ENTRIES;
|
|
291
|
+
const outcomes = entries.map((entry) => deprecateLegacyWorkbuddySkill({
|
|
292
|
+
configDir: options.configDir,
|
|
293
|
+
skillDir: entry.dir,
|
|
294
|
+
published: entry.published,
|
|
295
|
+
}));
|
|
296
|
+
return {
|
|
297
|
+
outcomes,
|
|
298
|
+
warnings: outcomes.flatMap((outcome) => outcome.warnings),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
168
301
|
//# sourceMappingURL=legacy-workbuddy-skill.js.map
|
|
@@ -66,7 +66,7 @@ export const WORKBUDDY_PLUGIN_KEY = `${WORKBUDDY_PLUGIN_NAME}@${WORKBUDDY_MARKET
|
|
|
66
66
|
const WORKBUDDY_REQUIRED_SKILLS = ['pd-cli-operator', 'pd-pain-signal', 'pd-review', 'pd-control'];
|
|
67
67
|
import { atomicReplaceTextFile, AtomicReplaceCleanupError, AtomicReplaceConflictError, errnoCode } from '../utils/config-file-io.js';
|
|
68
68
|
import { checkMcpRegistrationConflict } from './mcp-registration-conflict.js';
|
|
69
|
-
import {
|
|
69
|
+
import { deprecateAllLegacyWorkbuddySkills } from './legacy-workbuddy-skill.js';
|
|
70
70
|
import { resolveMcpServerDir, resolveMcpServerEntry } from '../mcp-server-layout-compat.js';
|
|
71
71
|
import { getHomeDir, generateConfigYamlContent, getConfigYamlPath, resolveDefaultModelForProvider, isValidHttpBaseUrl } from '../mvp-config.js';
|
|
72
72
|
// Type-only import from @principles/core — erased at compile time; this
|
|
@@ -2554,11 +2554,12 @@ export class WorkBuddyHostInstaller {
|
|
|
2554
2554
|
const pendingRebindNote = profilePendingAgents.length > 0
|
|
2555
2555
|
? ` Pending config: agent(s) ${profilePendingAgents.join(', ')} still bind to their explicit runtime profiles; to rebind them to the install profile, set internalAgents.agents.<name>.runtimeProfile to '${GOVERNANCE_PROFILE_ID}' (or remove the per-agent runtimeProfile row so they inherit internalAgents.defaultRuntime) in ${path.join(p.governanceDir, '.pd', 'config.yaml')}.`
|
|
2556
2556
|
: '';
|
|
2557
|
-
// SPEC-PD-AGENT-PAIN-INGRESS-001 §5.5 / TD §7.4: retire
|
|
2558
|
-
//
|
|
2559
|
-
//
|
|
2560
|
-
//
|
|
2561
|
-
|
|
2557
|
+
// SPEC-PD-AGENT-PAIN-INGRESS-001 §5.5 / TD §7.4: retire every old
|
|
2558
|
+
// user-level PD skill once per install/upgrade (`pd-record-pain` plus the
|
|
2559
|
+
// Codex-era pd-status/pd-setup/pd-disable and the pre-unification
|
|
2560
|
+
// pd-review). Idempotent and preservation-first: a copy that is not
|
|
2561
|
+
// provably a published payload is reported, never overwritten or deleted.
|
|
2562
|
+
const legacySkill = deprecateAllLegacyWorkbuddySkills({ configDir: p.configDir });
|
|
2562
2563
|
return {
|
|
2563
2564
|
success: true,
|
|
2564
2565
|
hostId: this.hostId,
|
|
@@ -19,6 +19,7 @@ import { readBootstrapManifest, readInstallConfig, resolvePdHomePaths, } from '.
|
|
|
19
19
|
import { appendJournalTransition, readActiveRecord, TransactionJournalError, } from './transaction-journal.js';
|
|
20
20
|
import { downloadReleaseAsset, extractAndVerifyReleaseAsset, ApplyPayloadError } from './apply-payload.js';
|
|
21
21
|
import { compareProductVersions, parseProductVersion } from './product-identity.js';
|
|
22
|
+
import { installManifestHostsForPersist, parseInstallManifest } from '@principles/install-layout';
|
|
22
23
|
export class ReleaseManagerError extends Error {
|
|
23
24
|
reason;
|
|
24
25
|
nextAction;
|
|
@@ -147,6 +148,44 @@ function toReleaseManagerError(error) {
|
|
|
147
148
|
const message = error instanceof Error ? error.message : String(error);
|
|
148
149
|
return new ReleaseManagerError('apply_failed', `Release application failed: ${message}`, 'The runtime was left on the previous release (installer backup/restore). Retry the update; if it fails again, run the official installer to repair.');
|
|
149
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* PRI-1204: the deployment host an update must target.
|
|
153
|
+
*
|
|
154
|
+
* `~/.pd/install.json` is the installer-owned record of the hosts this
|
|
155
|
+
* installation serves. No caller of `apply()` supplies a host (the console
|
|
156
|
+
* request carries none), so this layer used to fall back to a literal
|
|
157
|
+
* `'openclaw'` — on a WorkBuddy-only (or Codex-only) installation the update
|
|
158
|
+
* was then deployed AS IF OpenClaw had been requested: the journal recorded a
|
|
159
|
+
* host the machine does not serve, the installer's manifest merge added
|
|
160
|
+
* `openclaw` to `hosts`, and OpenClaw-specific writes ran on a machine with no
|
|
161
|
+
* OpenClaw. The recorded host is the truth.
|
|
162
|
+
*
|
|
163
|
+
* One target is enough: the installer's own upgrade plan refreshes every OTHER
|
|
164
|
+
* installed host in the same run (`resolveHostRefreshTargets`).
|
|
165
|
+
*
|
|
166
|
+
* A legacy install.json without the manifest fields keeps the historical
|
|
167
|
+
* default — there is no record to contradict it.
|
|
168
|
+
*/
|
|
169
|
+
function resolveDeploymentHost(installConfigPath) {
|
|
170
|
+
let value;
|
|
171
|
+
try {
|
|
172
|
+
value = JSON.parse(fs.readFileSync(installConfigPath, 'utf8'));
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return 'openclaw';
|
|
176
|
+
}
|
|
177
|
+
const parsed = parseInstallManifest(value);
|
|
178
|
+
if (!parsed.manifest)
|
|
179
|
+
return 'openclaw';
|
|
180
|
+
const recorded = installManifestHostsForPersist(parsed.manifest);
|
|
181
|
+
if (recorded.includes('openclaw'))
|
|
182
|
+
return 'openclaw';
|
|
183
|
+
if (recorded.includes('workbuddy'))
|
|
184
|
+
return 'workbuddy';
|
|
185
|
+
if (recorded.includes('codex'))
|
|
186
|
+
return 'codex';
|
|
187
|
+
return 'openclaw';
|
|
188
|
+
}
|
|
150
189
|
/**
|
|
151
190
|
* Single authority for active.json: the transaction journal's strict reader
|
|
152
191
|
* (schemaVersion + full field set). This adapter only maps its corruption
|
|
@@ -250,6 +289,10 @@ export class ReleaseManager {
|
|
|
250
289
|
if (status.layout === 'legacy-overlay') {
|
|
251
290
|
throw new ReleaseManagerError('legacy_layout_not_supported', 'This installation uses the legacy overlay layout, which the transactional updater does not serve.', 'Run the official installer to repair this installation into the supported layout, then retry.');
|
|
252
291
|
}
|
|
292
|
+
// PRI-1204: the host this update deploys into comes from the installation
|
|
293
|
+
// record, not from a literal. Resolved once, before any side effect, so the
|
|
294
|
+
// journal, the installer call, and the manifest merge all state ONE target.
|
|
295
|
+
const deploymentHost = options.host ?? resolveDeploymentHost(this.paths.installConfigPath);
|
|
253
296
|
// Pre-transaction resolution phase: no side effects have happened, so any
|
|
254
297
|
// refusal here is a clean, unjournaled refusal — still mapped onto the
|
|
255
298
|
// typed ReleaseManagerError contract (rc-9), never a raw transport error.
|
|
@@ -348,7 +391,7 @@ export class ReleaseManager {
|
|
|
348
391
|
// transaction BEFORE the first side effect. If even 'planned' cannot be
|
|
349
392
|
// written, refuse with zero side effects.
|
|
350
393
|
try {
|
|
351
|
-
appendApplyTransition(journal, 'planned', `host=${
|
|
394
|
+
appendApplyTransition(journal, 'planned', `host=${deploymentHost} mode=smart source=release-manager`);
|
|
352
395
|
}
|
|
353
396
|
catch (error) {
|
|
354
397
|
// PRI-897 (CR-1): the O_EXCL create is the ATOMIC seal. If two writers
|
|
@@ -387,7 +430,7 @@ export class ReleaseManager {
|
|
|
387
430
|
workspaceDir: options.workspaceDir,
|
|
388
431
|
channels: [],
|
|
389
432
|
overwriteConfig: false,
|
|
390
|
-
host:
|
|
433
|
+
host: deploymentHost,
|
|
391
434
|
stopGateway: true,
|
|
392
435
|
}, payloadDir, { quiet: true, nonInteractive: true }, journal);
|
|
393
436
|
if (!installResult.success) {
|
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
* sessions sample more names — a wrong guess is worse than a gap (unknown
|
|
17
17
|
* names resolve to 'other' and are never fabricated into Write/Bash
|
|
18
18
|
* equivalences).
|
|
19
|
+
*
|
|
20
|
+
* `pd_submit_pain` is the OG-4 MCP write tool (Owner-authorized for all three
|
|
21
|
+
* hosts on 2026-11-13), and it is deliberately NOT declared here:
|
|
22
|
+
* `CanonicalKind` is a FILE-mutation axis, and `workbuddy-rule-context-provider`
|
|
23
|
+
* only marks facts incomplete for `'execute' | 'other'`. Declaring a ledger
|
|
24
|
+
* write as `'write'` would make it count inside
|
|
25
|
+
* `computeBehaviorFacts.writeCount` while its payload carries no target path,
|
|
26
|
+
* and would switch off the conservative guard for every session that submits a
|
|
27
|
+
* pain. It therefore stays `'other'` — the same "a wrong guess is worse than a
|
|
28
|
+
* gap" rule as the rest of this declaration. The host's `*` PreToolUse matcher
|
|
29
|
+
* still delivers the event, so the call remains observable.
|
|
19
30
|
*/
|
|
20
31
|
import { type ToolSemanticMappingV1, type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
21
32
|
export declare const WORKBUDDY_TOOL_SEMANTIC_MAPPINGS: readonly ToolSemanticMappingV1[];
|
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
* sessions sample more names — a wrong guess is worse than a gap (unknown
|
|
17
17
|
* names resolve to 'other' and are never fabricated into Write/Bash
|
|
18
18
|
* equivalences).
|
|
19
|
+
*
|
|
20
|
+
* `pd_submit_pain` is the OG-4 MCP write tool (Owner-authorized for all three
|
|
21
|
+
* hosts on 2026-11-13), and it is deliberately NOT declared here:
|
|
22
|
+
* `CanonicalKind` is a FILE-mutation axis, and `workbuddy-rule-context-provider`
|
|
23
|
+
* only marks facts incomplete for `'execute' | 'other'`. Declaring a ledger
|
|
24
|
+
* write as `'write'` would make it count inside
|
|
25
|
+
* `computeBehaviorFacts.writeCount` while its payload carries no target path,
|
|
26
|
+
* and would switch off the conservative guard for every session that submits a
|
|
27
|
+
* pain. It therefore stays `'other'` — the same "a wrong guess is worse than a
|
|
28
|
+
* gap" rule as the rest of this declaration. The host's `*` PreToolUse matcher
|
|
29
|
+
* still delivers the event, so the call remains observable.
|
|
19
30
|
*/
|
|
20
31
|
import { buildToolSemanticRegistry } from '@principles/core/runtime';
|
|
21
32
|
export const WORKBUDDY_TOOL_SEMANTIC_MAPPINGS = Object.freeze([
|