create-principles-disciple 1.153.4 → 1.154.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/ingestion/codex-home.d.ts +1 -0
- package/codex-adapter/dist/ingestion/codex-home.js +19 -7
- package/codex-adapter/dist/ingestion/ingestion.js +34 -7
- package/codex-adapter/dist/pd-hook.js +14 -6
- package/codex-adapter/dist/worker/workspace-worker.js +31 -1
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/index.js +5 -16
- package/console/dist/server/utils/installed-layout.js +6 -4
- package/console/dist/server/utils/pd-backups.d.ts +1 -14
- package/console/dist/server/utils/pd-backups.js +12 -64
- package/console/dist/web/assets/app.css +67 -9
- package/console/dist/web/assets/app.js +37 -37
- package/console/dist/web/assets/providers/anthropic.png +0 -0
- package/console/dist/web/assets/providers/deepseek.png +0 -0
- package/console/dist/web/assets/providers/google.png +0 -0
- package/console/dist/web/assets/providers/groq.svg +1 -0
- package/console/dist/web/assets/providers/kimi.png +0 -0
- package/console/dist/web/assets/providers/minimax.png +0 -0
- package/console/dist/web/assets/providers/mistral.svg +28 -0
- package/console/dist/web/assets/providers/nvidia.png +0 -0
- package/console/dist/web/assets/providers/openai.svg +1 -0
- package/console/dist/web/assets/providers/openrouter.svg +3 -0
- package/console/dist/web/assets/providers/qwen.png +0 -0
- package/console/dist/web/assets/providers/together.svg +21 -0
- package/console/dist/web/assets/providers/xai.svg +1 -0
- package/console/dist/web/assets/providers/xiaomi.png +0 -0
- package/console/dist/web/assets/providers/zai.svg +219 -0
- package/core/dist/index.d.ts +1 -2
- package/core/dist/index.d.ts.map +1 -1
- package/core/dist/index.js +4 -2
- package/core/dist/index.js.map +1 -1
- package/core/dist/prompt-builder/focus-compression.d.ts +8 -60
- package/core/dist/prompt-builder/focus-compression.d.ts.map +1 -1
- package/core/dist/prompt-builder/focus-compression.js +8 -434
- package/core/dist/prompt-builder/focus-compression.js.map +1 -1
- package/core/dist/prompt-builder/index.d.ts +1 -2
- package/core/dist/prompt-builder/index.d.ts.map +1 -1
- package/core/dist/prompt-builder/index.js +3 -2
- package/core/dist/prompt-builder/index.js.map +1 -1
- package/core/dist/runtime/activation/production-gate-deps.d.ts +7 -3
- package/core/dist/runtime/activation/production-gate-deps.d.ts.map +1 -1
- package/core/dist/runtime/activation/production-gate-deps.js +15 -6
- package/core/dist/runtime/activation/production-gate-deps.js.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +2 -0
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js +9 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js.map +1 -1
- package/core/dist/runtime/config/pd-config-types.d.ts +20 -1
- package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.js +12 -1
- package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime/internalization/bash-risk.d.ts.map +1 -1
- package/core/dist/runtime/internalization/bash-risk.js +6 -3
- package/core/dist/runtime/internalization/bash-risk.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +28 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.js +109 -13
- package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +10 -0
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.js +6 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
- package/core/dist/runtime/pain-chain-read-model.d.ts +14 -0
- package/core/dist/runtime/pain-chain-read-model.d.ts.map +1 -1
- package/core/dist/runtime/pain-chain-read-model.js +91 -3
- package/core/dist/runtime/pain-chain-read-model.js.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.d.ts +15 -0
- package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.js +32 -3
- package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts +8 -0
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +11 -0
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js +3 -0
- package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime/pain-submit-capability.d.ts +54 -0
- package/core/dist/runtime/pain-submit-capability.d.ts.map +1 -1
- package/core/dist/runtime/pain-submit-capability.js +49 -1
- package/core/dist/runtime/pain-submit-capability.js.map +1 -1
- package/core/dist/runtime/storage-paths.d.ts +9 -10
- package/core/dist/runtime/storage-paths.d.ts.map +1 -1
- package/core/dist/runtime/storage-paths.js +9 -10
- package/core/dist/runtime/storage-paths.js.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.js +10 -2
- package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime/store/storage-paths.d.ts +65 -12
- package/core/dist/runtime/store/storage-paths.d.ts.map +1 -1
- package/core/dist/runtime/store/storage-paths.js +92 -39
- package/core/dist/runtime/store/storage-paths.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/installer.d.ts +113 -9
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +596 -100
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts +23 -3
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +36 -20
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/installers/index.d.ts.map +1 -1
- package/dist/installers/index.js +24 -3
- package/dist/installers/index.js.map +1 -1
- package/dist/installers/mcp-registration-conflict.d.ts.map +1 -1
- package/dist/installers/mcp-registration-conflict.js +23 -16
- package/dist/installers/mcp-registration-conflict.js.map +1 -1
- package/dist/installers/openclaw-host-installer.d.ts.map +1 -1
- package/dist/installers/openclaw-host-installer.js +1 -8
- package/dist/installers/openclaw-host-installer.js.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +7 -7
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/dist/mvp-config.d.ts +30 -5
- package/dist/mvp-config.d.ts.map +1 -1
- package/dist/mvp-config.js +49 -16
- package/dist/mvp-config.js.map +1 -1
- package/dist/prompts.js +1 -1
- package/dist/prompts.js.map +1 -1
- package/dist/uninstaller.d.ts.map +1 -1
- package/dist/uninstaller.js +142 -5
- package/dist/uninstaller.js.map +1 -1
- package/dist/update/release-manager.d.ts.map +1 -1
- package/dist/update/release-manager.js +5 -2
- package/dist/update/release-manager.js.map +1 -1
- package/dist/utils/env.d.ts +5 -10
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +91 -34
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/host-workspace-ownership.d.ts +25 -0
- package/dist/utils/host-workspace-ownership.d.ts.map +1 -1
- package/dist/utils/host-workspace-ownership.js +153 -2
- package/dist/utils/host-workspace-ownership.js.map +1 -1
- package/host-runtime/dist/adaptive-background-append.d.ts +6 -0
- package/host-runtime/dist/adaptive-background-append.js +4 -1
- package/host-runtime/dist/adaptive-decision-protocol.d.ts +18 -2
- package/host-runtime/dist/adaptive-decision-protocol.js +39 -9
- package/host-runtime/dist/adaptive-principle-context-reader.d.ts +79 -0
- package/host-runtime/dist/adaptive-principle-context-reader.js +303 -0
- package/host-runtime/dist/adaptive-priority-provider.d.ts +33 -0
- package/host-runtime/dist/adaptive-priority-provider.js +68 -2
- package/host-runtime/dist/adaptive-selection.d.ts +16 -0
- package/host-runtime/dist/adaptive-selection.js +23 -1
- package/host-runtime/dist/codex-legacy-registration.js +10 -2
- package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +8 -0
- package/host-runtime/dist/conversation-ingestion/pipeline.js +179 -7
- package/host-runtime/dist/degraded-enforcement-marker.js +16 -2
- package/host-runtime/dist/diagnostician-auto-run.js +4 -0
- package/host-runtime/dist/governance-observation-store.d.ts +44 -0
- package/host-runtime/dist/governance-observation-store.js +84 -1
- package/host-runtime/dist/governance-trajectory-turn-reader.d.ts +30 -0
- package/host-runtime/dist/governance-trajectory-turn-reader.js +47 -0
- package/host-runtime/dist/index.d.ts +2 -0
- package/host-runtime/dist/index.js +6 -0
- package/host-runtime/dist/product-telemetry/service.js +86 -20
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/index.d.ts +23 -9
- package/install-layout/dist/index.js +49 -24
- package/install-layout/dist/mcp-binding-contract.d.ts +62 -0
- package/install-layout/dist/mcp-binding-contract.js +175 -3
- package/install-layout/dist/pd-home.d.ts +35 -5
- package/install-layout/dist/pd-home.js +138 -23
- package/install-layout/package.json +1 -1
- package/package.json +4 -4
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +134 -8
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/codex-worker.js +36 -2
- package/pd-cli/dist/commands/codex-worker.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +34 -8
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/health-codex-install.d.ts +1 -3
- package/pd-cli/dist/commands/health-codex-install.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-codex-install.js +19 -6
- package/pd-cli/dist/commands/health-codex-install.js.map +1 -1
- package/pd-cli/dist/commands/health-codex.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-codex.js +27 -9
- package/pd-cli/dist/commands/health-codex.js.map +1 -1
- package/pd-cli/dist/commands/health-console.d.ts +2 -1
- package/pd-cli/dist/commands/health-console.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-console.js +12 -3
- package/pd-cli/dist/commands/health-console.js.map +1 -1
- package/pd-cli/dist/commands/health-ingestion.d.ts +10 -2
- package/pd-cli/dist/commands/health-ingestion.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-ingestion.js +56 -14
- package/pd-cli/dist/commands/health-ingestion.js.map +1 -1
- package/pd-cli/dist/commands/health-mcp.d.ts +19 -7
- package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-mcp.js +131 -45
- package/pd-cli/dist/commands/health-mcp.js.map +1 -1
- package/pd-cli/dist/commands/health-workbuddy.d.ts +2 -1
- package/pd-cli/dist/commands/health-workbuddy.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-workbuddy.js +17 -8
- package/pd-cli/dist/commands/health-workbuddy.js.map +1 -1
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +12 -5
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/mcp-probe.d.ts +6 -0
- package/pd-cli/dist/commands/mcp-probe.d.ts.map +1 -1
- package/pd-cli/dist/commands/mcp-probe.js +35 -7
- package/pd-cli/dist/commands/mcp-probe.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +10 -2
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/dist/commands/trace.d.ts.map +1 -1
- package/pd-cli/dist/commands/trace.js +8 -0
- package/pd-cli/dist/commands/trace.js.map +1 -1
- package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -1
- package/pd-cli/dist/commands/workbuddy-setup.js +7 -3
- package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -1
- package/pd-cli/dist/commands/workbuddy-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/workbuddy-worker.js +21 -6
- package/pd-cli/dist/commands/workbuddy-worker.js.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.d.ts +10 -1
- package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.js +12 -2
- package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
- package/pd-cli/dist/services/codex-plugin-install.d.ts +1 -3
- package/pd-cli/dist/services/codex-plugin-install.d.ts.map +1 -1
- package/pd-cli/dist/services/codex-plugin-install.js +10 -3
- package/pd-cli/dist/services/codex-plugin-install.js.map +1 -1
- package/pd-cli/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/pain-flood-simulation-runner.js +2 -0
- package/pd-cli/dist/services/pain-flood-simulation-runner.js.map +1 -1
- package/pd-cli/dist/services/pd-config-loader.d.ts +2 -2
- package/pd-cli/dist/services/pd-config-loader.d.ts.map +1 -1
- package/pd-cli/dist/services/pd-config-loader.js +28 -20
- package/pd-cli/dist/services/pd-config-loader.js.map +1 -1
- package/pd-cli/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/synthetic-baseline-runner.js +2 -0
- package/pd-cli/dist/services/synthetic-baseline-runner.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/pd-mcp-server/dist/log-file.js +9 -2
- package/pd-mcp-server/dist/server.d.ts +52 -2
- package/pd-mcp-server/dist/server.js +40 -4
- package/pd-mcp-server/dist/submit-assembly.js +85 -12
- 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 +1 -1
- package/plugin/dist/bundle.js +761 -722
- package/plugin/dist/commands/focus.d.ts +10 -7
- package/plugin/dist/commands/strategy.d.ts +10 -0
- package/plugin/dist/core/focus-history.d.ts +9 -49
- package/plugin/dist/core/paths.d.ts +6 -53
- package/plugin/dist/governance-audit.js +2 -2
- package/plugin/dist/hooks/prompt-helpers.d.ts +6 -5
- package/plugin/dist/hooks/prompt-types.d.ts +6 -6
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +29 -29
- package/plugin/dist/templates/workspace/okr/RECOVERY_PROTOCOL.md +8 -7
- package/plugin/dist/utils/io.d.ts +1 -1
- package/plugin/dist/utils/workspace-resolver.d.ts +0 -20
- package/plugin/mcp/launcher.cjs +159 -35
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/plugin/templates/workspace/okr/RECOVERY_PROTOCOL.md +8 -7
- package/release-manager/dist/installer.js +596 -100
- package/release-manager/dist/installers/codex-host-installer.js +36 -20
- package/release-manager/dist/installers/index.js +24 -3
- package/release-manager/dist/installers/mcp-registration-conflict.js +23 -16
- package/release-manager/dist/installers/openclaw-host-installer.js +1 -8
- package/release-manager/dist/installers/workbuddy-host-installer.js +7 -7
- package/release-manager/dist/mvp-config.js +49 -16
- package/release-manager/dist/update/release-manager.js +5 -2
- package/release-manager/dist/utils/env.js +91 -34
- package/release-manager/dist/utils/host-workspace-ownership.js +153 -2
- package/release-manager/package.json +2 -2
- package/workbuddy-adapter/dist/index.d.ts +1 -1
- package/workbuddy-adapter/dist/index.js +1 -1
- package/workbuddy-adapter/dist/ingestion/catch-up.js +15 -3
- package/workbuddy-adapter/dist/ingestion/index.d.ts +1 -1
- package/workbuddy-adapter/dist/ingestion/index.js +1 -1
- package/workbuddy-adapter/dist/ingestion/ingestion.d.ts +18 -0
- package/workbuddy-adapter/dist/ingestion/ingestion.js +20 -2
- package/workbuddy-adapter/dist/ingestion/transcript-path.d.ts +13 -4
- package/workbuddy-adapter/dist/ingestion/transcript-path.js +102 -4
- package/workbuddy-adapter/dist/ingestion/transcript-source.js +76 -58
- package/workbuddy-adapter/dist/pd-hook.js +10 -3
- package/workbuddy-adapter/dist/worker/workspace-worker.js +4 -1
- package/workbuddy-adapter/dist/workspace-resolution.d.ts +9 -2
- package/workbuddy-adapter/dist/workspace-resolution.js +19 -3
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/mcp/launcher.cjs +159 -35
- package/plugin/dist/templates/workspace/okr/CURRENT_FOCUS.md +0 -56
- package/plugin/dist/templates/workspace/okr/TASK_CHANGES.jsonl +0 -6
- package/plugin/dist/templates/workspace/okr/WEEK_TASKS.json +0 -6
- package/plugin/templates/workspace/okr/CURRENT_FOCUS.md +0 -56
- package/plugin/templates/workspace/okr/TASK_CHANGES.jsonl +0 -6
- package/plugin/templates/workspace/okr/WEEK_TASKS.json +0 -6
|
@@ -45,6 +45,10 @@ export interface McpHostWorkspaceOptions {
|
|
|
45
45
|
readonly homeDir: string;
|
|
46
46
|
/** Codex home override (`CODEX_HOME`); defaults to `<homeDir>/.codex`. */
|
|
47
47
|
readonly codexHome?: string;
|
|
48
|
+
/** OpenClaw state/home override; defaults to `<homeDir>/.openclaw`. */
|
|
49
|
+
readonly openclawHome?: string;
|
|
50
|
+
/** WorkBuddy config root override; defaults to `<homeDir>/.workbuddy`. */
|
|
51
|
+
readonly workbuddyConfigDir?: string;
|
|
48
52
|
/** Node's `process.platform` value, injected so the win32 rule is testable. */
|
|
49
53
|
readonly platform: string;
|
|
50
54
|
}
|
|
@@ -67,6 +71,64 @@ export declare function getHostDefaultWorkspaceDirs(host: McpBindingHost, option
|
|
|
67
71
|
* health time (Codex installer) or in `pd health`.
|
|
68
72
|
*/
|
|
69
73
|
export declare function findForeignWorkspaceHost(host: McpBindingHost, workspaceDir: string, options: McpHostWorkspaceOptions): McpBindingHost | null;
|
|
74
|
+
/**
|
|
75
|
+
* How a host came to OWN a workspace directory:
|
|
76
|
+
* - `default` — the host's default governance workspace tree;
|
|
77
|
+
* - `host_declaration`— the Owner's explicit PD declaration file
|
|
78
|
+
* (`~/.openclaw/principles-disciple.json` /
|
|
79
|
+
* `~/.principles/principles-disciple.json` `workspace`);
|
|
80
|
+
* - `payload_binding` — the host payload's own `mcp-binding.json`
|
|
81
|
+
* (`workspaceDir`), the binding-writer authority for
|
|
82
|
+
* Codex (PLUGIN_DATA, PRI-1248) and WorkBuddy
|
|
83
|
+
* (marketplace copy).
|
|
84
|
+
*/
|
|
85
|
+
export type HostWorkspaceClaimVia = 'default' | 'host_declaration' | 'payload_binding';
|
|
86
|
+
export interface HostWorkspaceClaim {
|
|
87
|
+
readonly host: McpBindingHost;
|
|
88
|
+
readonly workspaceDir: string;
|
|
89
|
+
readonly via: HostWorkspaceClaimVia;
|
|
90
|
+
/** Where the claim was read from (diagnostics; never a secret). */
|
|
91
|
+
readonly source: string;
|
|
92
|
+
}
|
|
93
|
+
/** Injectable filesystem surface so the collector stays deterministic in tests. */
|
|
94
|
+
export interface HostClaimReaders {
|
|
95
|
+
readJson(file: string): Record<string, unknown> | undefined;
|
|
96
|
+
listDir(dir: string): string[] | undefined;
|
|
97
|
+
/** Canonical (realpath) identity, or undefined when unresolvable. */
|
|
98
|
+
realpath(target: string): string | undefined;
|
|
99
|
+
}
|
|
100
|
+
export interface HostClaimOptions extends McpHostWorkspaceOptions {
|
|
101
|
+
readonly readers?: HostClaimReaders;
|
|
102
|
+
}
|
|
103
|
+
export interface ForeignWorkspaceOwnerVerdict {
|
|
104
|
+
/** Every OTHER host that owns `workspaceDir`; empty = not foreign. */
|
|
105
|
+
readonly owners: readonly McpBindingHost[];
|
|
106
|
+
/** The matched claims (evidence for the refusal). */
|
|
107
|
+
readonly claims: readonly HostWorkspaceClaim[];
|
|
108
|
+
/** How ownership was established for the first matched claim. */
|
|
109
|
+
readonly via: HostWorkspaceClaimVia | null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Collect every host's ownership claims: default trees, the Owner's explicit
|
|
113
|
+
* declaration files, and the other hosts' payload bindings. One judgment for
|
|
114
|
+
* the installer, the binding health check, `pd health`, pd-setup and the
|
|
115
|
+
* launcher mirror (parity test pins both sides together).
|
|
116
|
+
*
|
|
117
|
+
* PRI-1247 reopen: default-dir enumeration alone accepted a NON-DEFAULT
|
|
118
|
+
* OpenClaw workspace formally declared in `principles-disciple.json` — the
|
|
119
|
+
* original incident's target. Declarations and payload bindings close that
|
|
120
|
+
* hole in every direction.
|
|
121
|
+
*/
|
|
122
|
+
export declare function collectHostWorkspaceClaims(options: HostClaimOptions): readonly HostWorkspaceClaim[];
|
|
123
|
+
/**
|
|
124
|
+
* The full cross-host ownership verdict (PRI-1247 reopen). Unlike the
|
|
125
|
+
* defaults-only {@link findForeignWorkspaceHost} this reads the hosts' FORMAL
|
|
126
|
+
* declarations and payload bindings, so a NON-DEFAULT workspace another host
|
|
127
|
+
* formally declared is refused too. Multiple owners are ALL reported — an
|
|
128
|
+
* ambiguous declaration set is the Owner's to fix, not the installer's to
|
|
129
|
+
* guess.
|
|
130
|
+
*/
|
|
131
|
+
export declare function findForeignWorkspaceOwner(host: McpBindingHost, workspaceDir: string, options: HostClaimOptions): ForeignWorkspaceOwnerVerdict;
|
|
70
132
|
/**
|
|
71
133
|
* Validate the binding SHAPE (and the canonical-entry rule) exactly as the
|
|
72
134
|
* launcher does. Filesystem facts — file present/readable, runtime dir and
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* Adding a reason code without a fixture/exemption makes the launcher parity
|
|
16
16
|
* test red — divergence is a defect, not something to remember.
|
|
17
17
|
*/
|
|
18
|
+
import * as fs from 'node:fs';
|
|
18
19
|
import * as path from 'node:path';
|
|
20
|
+
import { PD_HOST_WORKSPACE_DIR_NAME } from './pd-home.js';
|
|
19
21
|
export const MCP_BINDING_SCHEMA_VERSION = 'pd.mcp-binding.v1';
|
|
20
22
|
export const MCP_BINDING_HOSTS = ['codex', 'openclaw', 'workbuddy'];
|
|
21
23
|
/**
|
|
@@ -72,13 +74,19 @@ export function getHostDefaultWorkspaceDirs(host, options) {
|
|
|
72
74
|
const codexHome = options.codexHome !== undefined
|
|
73
75
|
? path.resolve(options.codexHome)
|
|
74
76
|
: path.join(home, '.codex');
|
|
77
|
+
const openclawHome = options.openclawHome !== undefined
|
|
78
|
+
? path.resolve(options.openclawHome)
|
|
79
|
+
: path.join(home, '.openclaw');
|
|
80
|
+
const workbuddyConfigDir = options.workbuddyConfigDir !== undefined
|
|
81
|
+
? path.resolve(options.workbuddyConfigDir)
|
|
82
|
+
: path.join(home, '.workbuddy');
|
|
75
83
|
switch (host) {
|
|
76
84
|
case 'openclaw':
|
|
77
|
-
return [path.join(home, 'clawd'), path.join(
|
|
85
|
+
return [path.join(home, 'clawd'), path.join(openclawHome, 'workspace')];
|
|
78
86
|
case 'codex':
|
|
79
|
-
return [path.join(codexHome,
|
|
87
|
+
return [path.join(codexHome, PD_HOST_WORKSPACE_DIR_NAME)];
|
|
80
88
|
case 'workbuddy':
|
|
81
|
-
return [path.join(
|
|
89
|
+
return [path.join(workbuddyConfigDir, PD_HOST_WORKSPACE_DIR_NAME)];
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
function isSameOrInside(parent, child, platform) {
|
|
@@ -119,6 +127,168 @@ export function findForeignWorkspaceHost(host, workspaceDir, options) {
|
|
|
119
127
|
}
|
|
120
128
|
return null;
|
|
121
129
|
}
|
|
130
|
+
const PD_DECLARATION_FILENAME = 'principles-disciple.json';
|
|
131
|
+
const WB_MARKETPLACE_PAYLOAD_SEGMENTS = ['.pd', 'workbuddy-marketplace', 'principles-disciple'];
|
|
132
|
+
const CODEX_PLUGIN_DATA_PREFIX = 'principles-disciple-';
|
|
133
|
+
function defaultHostClaimReaders() {
|
|
134
|
+
return {
|
|
135
|
+
readJson(file) {
|
|
136
|
+
try {
|
|
137
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
138
|
+
// rc-1/rc-2: the type guard narrows without an `as` cast.
|
|
139
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
listDir(dir) {
|
|
146
|
+
try {
|
|
147
|
+
return fs.readdirSync(dir);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
realpath(target) {
|
|
154
|
+
try {
|
|
155
|
+
return fs.realpathSync.native(target);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function readWorkspaceFromDeclaration(readers, file) {
|
|
164
|
+
const parsed = readers.readJson(file);
|
|
165
|
+
if (parsed === undefined)
|
|
166
|
+
return undefined;
|
|
167
|
+
const value = parsed.workspace;
|
|
168
|
+
if (typeof value !== 'string' || value.trim().length === 0)
|
|
169
|
+
return undefined;
|
|
170
|
+
if (!path.isAbsolute(value.trim()))
|
|
171
|
+
return undefined;
|
|
172
|
+
return path.resolve(value.trim());
|
|
173
|
+
}
|
|
174
|
+
function readWorkspaceFromBinding(readers, file) {
|
|
175
|
+
const parsed = readers.readJson(file);
|
|
176
|
+
if (parsed === undefined)
|
|
177
|
+
return undefined;
|
|
178
|
+
const value = parsed.workspaceDir;
|
|
179
|
+
if (typeof value !== 'string' || value.trim().length === 0)
|
|
180
|
+
return undefined;
|
|
181
|
+
if (!path.isAbsolute(value.trim()))
|
|
182
|
+
return undefined;
|
|
183
|
+
return path.resolve(value.trim());
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Collect every host's ownership claims: default trees, the Owner's explicit
|
|
187
|
+
* declaration files, and the other hosts' payload bindings. One judgment for
|
|
188
|
+
* the installer, the binding health check, `pd health`, pd-setup and the
|
|
189
|
+
* launcher mirror (parity test pins both sides together).
|
|
190
|
+
*
|
|
191
|
+
* PRI-1247 reopen: default-dir enumeration alone accepted a NON-DEFAULT
|
|
192
|
+
* OpenClaw workspace formally declared in `principles-disciple.json` — the
|
|
193
|
+
* original incident's target. Declarations and payload bindings close that
|
|
194
|
+
* hole in every direction.
|
|
195
|
+
*/
|
|
196
|
+
export function collectHostWorkspaceClaims(options) {
|
|
197
|
+
const home = path.resolve(options.homeDir);
|
|
198
|
+
const codexHome = options.codexHome !== undefined
|
|
199
|
+
? path.resolve(options.codexHome)
|
|
200
|
+
: path.join(home, '.codex');
|
|
201
|
+
const openclawHome = options.openclawHome !== undefined
|
|
202
|
+
? path.resolve(options.openclawHome)
|
|
203
|
+
: path.join(home, '.openclaw');
|
|
204
|
+
const readers = options.readers ?? defaultHostClaimReaders();
|
|
205
|
+
const claims = [];
|
|
206
|
+
for (const host of MCP_BINDING_HOSTS) {
|
|
207
|
+
for (const dir of getHostDefaultWorkspaceDirs(host, options)) {
|
|
208
|
+
claims.push({ host, workspaceDir: dir, via: 'default', source: 'default' });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// The declaration lives under the host's ACTUAL config root: the launcher
|
|
212
|
+
// resolves OPENCLAW_STATE_DIR/OPENCLAW_HOME into roots.openclawHome, so a
|
|
213
|
+
// fixed `<home>/.openclaw` read misses a declaration under a custom root
|
|
214
|
+
// and accepts a binding the launcher then refuses (review 2026-11-18).
|
|
215
|
+
for (const file of [path.join(openclawHome, PD_DECLARATION_FILENAME), path.join(home, '.principles', PD_DECLARATION_FILENAME)]) {
|
|
216
|
+
const declared = readWorkspaceFromDeclaration(readers, file);
|
|
217
|
+
if (declared !== undefined) {
|
|
218
|
+
claims.push({ host: 'openclaw', workspaceDir: declared, via: 'host_declaration', source: file });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const dataRoot = path.join(codexHome, 'plugins', 'data');
|
|
222
|
+
const entries = readers.listDir(dataRoot) ?? [];
|
|
223
|
+
for (const entry of entries) {
|
|
224
|
+
if (typeof entry !== 'string' || !entry.startsWith(CODEX_PLUGIN_DATA_PREFIX))
|
|
225
|
+
continue;
|
|
226
|
+
const binding = path.join(dataRoot, entry, 'mcp-binding.json');
|
|
227
|
+
const bound = readWorkspaceFromBinding(readers, binding);
|
|
228
|
+
if (bound !== undefined) {
|
|
229
|
+
claims.push({ host: 'codex', workspaceDir: bound, via: 'payload_binding', source: binding });
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const wbBinding = path.join(home, ...WB_MARKETPLACE_PAYLOAD_SEGMENTS, 'mcp-binding.json');
|
|
233
|
+
const wbBound = readWorkspaceFromBinding(readers, wbBinding);
|
|
234
|
+
if (wbBound !== undefined) {
|
|
235
|
+
claims.push({ host: 'workbuddy', workspaceDir: wbBound, via: 'payload_binding', source: wbBinding });
|
|
236
|
+
}
|
|
237
|
+
return claims;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Identity of a directory for ownership comparison: the REAL path when it
|
|
241
|
+
* resolves (junctions/symlinks/case folded by the OS), else the resolved
|
|
242
|
+
* lexical form. Windows compares case-insensitively, matching the launcher's
|
|
243
|
+
* `samePath` rule.
|
|
244
|
+
*/
|
|
245
|
+
function workspaceIdentity(dir, readers, platform) {
|
|
246
|
+
const real = readers.realpath(dir);
|
|
247
|
+
const resolved = real !== undefined ? real : path.resolve(dir);
|
|
248
|
+
return platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The full cross-host ownership verdict (PRI-1247 reopen). Unlike the
|
|
252
|
+
* defaults-only {@link findForeignWorkspaceHost} this reads the hosts' FORMAL
|
|
253
|
+
* declarations and payload bindings, so a NON-DEFAULT workspace another host
|
|
254
|
+
* formally declared is refused too. Multiple owners are ALL reported — an
|
|
255
|
+
* ambiguous declaration set is the Owner's to fix, not the installer's to
|
|
256
|
+
* guess.
|
|
257
|
+
*/
|
|
258
|
+
export function findForeignWorkspaceOwner(host, workspaceDir, options) {
|
|
259
|
+
const empty = { owners: [], claims: [], via: null };
|
|
260
|
+
if (workspaceDir.trim().length === 0)
|
|
261
|
+
return empty;
|
|
262
|
+
const readers = options.readers ?? defaultHostClaimReaders();
|
|
263
|
+
const target = workspaceIdentity(workspaceDir, readers, options.platform);
|
|
264
|
+
const owners = [];
|
|
265
|
+
const matched = [];
|
|
266
|
+
for (const claim of collectHostWorkspaceClaims({ ...options, readers })) {
|
|
267
|
+
if (claim.host === host)
|
|
268
|
+
continue;
|
|
269
|
+
if (claim.workspaceDir.trim().length === 0)
|
|
270
|
+
continue;
|
|
271
|
+
const claimIdentity = workspaceIdentity(claim.workspaceDir, readers, options.platform);
|
|
272
|
+
const same = claimIdentity === target;
|
|
273
|
+
// Inside-check on BOTH forms: lexical (declaration paths that do not exist
|
|
274
|
+
// yet) and real identities (a binding whose path reaches the claim tree
|
|
275
|
+
// through a junction must not escape the ownership check).
|
|
276
|
+
const relative = path.relative(claimIdentity, target);
|
|
277
|
+
const insideIdentity = !same && relative !== '' && !path.isAbsolute(relative)
|
|
278
|
+
&& relative !== '..' && !relative.startsWith(`..${path.sep}`);
|
|
279
|
+
const insideLexical = !same && isSameOrInside(claim.workspaceDir, workspaceDir, options.platform);
|
|
280
|
+
if (same || insideIdentity || insideLexical) {
|
|
281
|
+
if (!owners.includes(claim.host))
|
|
282
|
+
owners.push(claim.host);
|
|
283
|
+
matched.push(claim);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
owners,
|
|
288
|
+
claims: matched,
|
|
289
|
+
via: matched.length > 0 ? matched[0].via : null,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
122
292
|
function reject(code, reason, nextAction) {
|
|
123
293
|
return { ok: false, code, reason, nextAction };
|
|
124
294
|
}
|
|
@@ -224,6 +394,8 @@ export const MCP_BINDING_LAUNCHER_ONLY_REASONS = [
|
|
|
224
394
|
{ code: 'experiment_mcp_log_dir_missing', why: 'An experiment must pin PD_MCP_LOG_DIR; the default is the production log directory.' },
|
|
225
395
|
{ code: 'experiment_mcp_log_dir_outside_root', why: 'An experiment MCP log directory must stay inside PD_EXPERIMENT_ROOT.' },
|
|
226
396
|
{ code: 'experiment_binding_workspace_outside_root', why: 'An experiment must never serve a binding workspace outside its own root.' },
|
|
397
|
+
{ code: 'experiment_host_config_invalid', why: 'An experiment must not inspect another host configuration root outside its own isolated root.' },
|
|
398
|
+
{ code: 'openclaw_state_dir_not_absolute', why: 'OPENCLAW_STATE_DIR is required to be absolute by the OpenClaw host contract.' },
|
|
227
399
|
];
|
|
228
400
|
/**
|
|
229
401
|
* Table-driven matrix shared by the contract test, the launcher parity test and
|
|
@@ -9,6 +9,12 @@ export declare const PD_OPENCLAW_HOME_ENV = "OPENCLAW_HOME";
|
|
|
9
9
|
* the host reads another.
|
|
10
10
|
*/
|
|
11
11
|
export declare const PD_OPENCLAW_STATE_DIR_ENV = "OPENCLAW_STATE_DIR";
|
|
12
|
+
/** Codex host configuration root override. */
|
|
13
|
+
export declare const PD_CODEX_HOME_ENV = "CODEX_HOME";
|
|
14
|
+
/** WorkBuddy host configuration root override. */
|
|
15
|
+
export declare const PD_WORKBUDDY_CONFIG_DIR_ENV = "WORKBUDDY_CONFIG_DIR";
|
|
16
|
+
/** Shared leaf directory for Codex and WorkBuddy user-level governance workspaces. */
|
|
17
|
+
export declare const PD_HOST_WORKSPACE_DIR_NAME = "pd-workspace";
|
|
12
18
|
export declare const PD_HOME_MODES: readonly ['production', 'experiment'];
|
|
13
19
|
export type PdHomeMode = (typeof PD_HOME_MODES)[number];
|
|
14
20
|
export interface PdHomePaths {
|
|
@@ -19,18 +25,30 @@ export interface PdHomePaths {
|
|
|
19
25
|
* `getInstallLayoutPaths(homeDir)` keeps working unchanged).
|
|
20
26
|
*/
|
|
21
27
|
readonly homeDir: string;
|
|
22
|
-
/** `<homeDir>/.pd` —
|
|
28
|
+
/** `<homeDir>/.pd` — PD installation and machine-level state root. */
|
|
23
29
|
readonly pdHome: string;
|
|
30
|
+
/** `<pdHome>/runtime` — shared, versioned PD runtime. */
|
|
31
|
+
readonly runtimeDir: string;
|
|
32
|
+
/** `<pdHome>/backups` — installer/runtime backups. */
|
|
33
|
+
readonly pdRuntimeBackupsDir: string;
|
|
24
34
|
/** `<homeDir>/.openclaw` (or `OPENCLAW_STATE_DIR` > `OPENCLAW_HOME`). */
|
|
25
35
|
readonly openclawHome: string;
|
|
26
|
-
/** `<
|
|
36
|
+
/** `<openclawHome>/extensions/principles-disciple` — host-owned plugin location. */
|
|
37
|
+
readonly openclawExtensionDir: string;
|
|
38
|
+
/** `<homeDir>/.pd-console` — existing Console workspace registry location. */
|
|
27
39
|
readonly consoleConfigDir: string;
|
|
28
|
-
/** `<homeDir>/.codex`
|
|
40
|
+
/** `<homeDir>/.codex` or explicit `CODEX_HOME`; host-owned config root. */
|
|
29
41
|
readonly codexHome: string;
|
|
42
|
+
/** `<codexHome>/pd-workspace` — existing Codex user-level governance workspace. */
|
|
43
|
+
readonly codexWorkspaceDir: string;
|
|
44
|
+
/** `<homeDir>/.workbuddy` or explicit `WORKBUDDY_CONFIG_DIR`; host-owned config root. */
|
|
45
|
+
readonly workbuddyConfigDir: string;
|
|
46
|
+
/** `<workbuddyConfigDir>/pd-workspace` — existing WorkBuddy shared governance workspace. */
|
|
47
|
+
readonly workbuddyWorkspaceDir: string;
|
|
30
48
|
/** Present only in experiment mode: the canonical (realpath'd) root. */
|
|
31
49
|
readonly experimentRoot?: string;
|
|
32
50
|
}
|
|
33
|
-
export declare const PD_HOME_FAILURE_REASONS: readonly ['experiment_root_empty', 'experiment_root_not_absolute', 'experiment_root_missing', 'experiment_root_not_directory', 'experiment_root_unresolvable', 'experiment_root_overlaps_production', 'experiment_path_escapes_root', 'openclaw_home_outside_experiment', 'openclaw_state_dir_not_absolute', 'openclaw_state_dir_outside_experiment'];
|
|
51
|
+
export declare const PD_HOME_FAILURE_REASONS: readonly ['experiment_root_empty', 'experiment_root_not_absolute', 'experiment_root_missing', 'experiment_root_not_directory', 'experiment_root_unresolvable', 'experiment_root_overlaps_production', 'experiment_path_escapes_root', 'openclaw_home_outside_experiment', 'openclaw_state_dir_not_absolute', 'openclaw_state_dir_outside_experiment', 'codex_home_not_absolute', 'codex_home_outside_experiment', 'workbuddy_config_dir_not_absolute', 'workbuddy_config_dir_outside_experiment'];
|
|
34
52
|
export type PdHomeFailureReason = (typeof PD_HOME_FAILURE_REASONS)[number];
|
|
35
53
|
export interface PdHomeFailure {
|
|
36
54
|
readonly ok: false;
|
|
@@ -46,9 +64,21 @@ export type PdHomeResolution = PdHomeSuccess | PdHomeFailure;
|
|
|
46
64
|
export interface ResolvePdHomeOptions {
|
|
47
65
|
/** Environment to read. Defaults to `process.env`; injected by tests. */
|
|
48
66
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
49
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Real user home. Defaults to the shared precedence below; injected by tests.
|
|
69
|
+
*/
|
|
50
70
|
readonly homeDir?: string;
|
|
51
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* The real-user-home precedence for EVERY PD Home resolution (single
|
|
74
|
+
* authority): an explicit `HOME` wins (POSIX semantics, plus the established
|
|
75
|
+
* test/CI sandbox contract — twenty-plus installer-family tests redirect
|
|
76
|
+
* `process.env.HOME`), then `os.homedir()` (USERPROFILE on Windows,
|
|
77
|
+
* passwd-based on POSIX). `os.homedir()` alone would silently ignore a
|
|
78
|
+
* sandboxed HOME on Windows and land every installer-family test on the real
|
|
79
|
+
* production home (ERR-083 OCC-20261117T190516Z).
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveRealUserHome(env?: Readonly<Record<string, string | undefined>>): string;
|
|
52
82
|
/**
|
|
53
83
|
* True when `candidate` is inside `root` (or equal to it). Uses
|
|
54
84
|
* `path.relative`, which on win32 compares case-insensitively — the reason not
|
|
@@ -36,6 +36,12 @@ export const PD_OPENCLAW_HOME_ENV = 'OPENCLAW_HOME';
|
|
|
36
36
|
* the host reads another.
|
|
37
37
|
*/
|
|
38
38
|
export const PD_OPENCLAW_STATE_DIR_ENV = 'OPENCLAW_STATE_DIR';
|
|
39
|
+
/** Codex host configuration root override. */
|
|
40
|
+
export const PD_CODEX_HOME_ENV = 'CODEX_HOME';
|
|
41
|
+
/** WorkBuddy host configuration root override. */
|
|
42
|
+
export const PD_WORKBUDDY_CONFIG_DIR_ENV = 'WORKBUDDY_CONFIG_DIR';
|
|
43
|
+
/** Shared leaf directory for Codex and WorkBuddy user-level governance workspaces. */
|
|
44
|
+
export const PD_HOST_WORKSPACE_DIR_NAME = 'pd-workspace';
|
|
39
45
|
export const PD_HOME_MODES = ['production', 'experiment'];
|
|
40
46
|
export const PD_HOME_FAILURE_REASONS = [
|
|
41
47
|
'experiment_root_empty',
|
|
@@ -48,7 +54,24 @@ export const PD_HOME_FAILURE_REASONS = [
|
|
|
48
54
|
'openclaw_home_outside_experiment',
|
|
49
55
|
'openclaw_state_dir_not_absolute',
|
|
50
56
|
'openclaw_state_dir_outside_experiment',
|
|
57
|
+
'codex_home_not_absolute',
|
|
58
|
+
'codex_home_outside_experiment',
|
|
59
|
+
'workbuddy_config_dir_not_absolute',
|
|
60
|
+
'workbuddy_config_dir_outside_experiment',
|
|
51
61
|
];
|
|
62
|
+
/**
|
|
63
|
+
* The real-user-home precedence for EVERY PD Home resolution (single
|
|
64
|
+
* authority): an explicit `HOME` wins (POSIX semantics, plus the established
|
|
65
|
+
* test/CI sandbox contract — twenty-plus installer-family tests redirect
|
|
66
|
+
* `process.env.HOME`), then `os.homedir()` (USERPROFILE on Windows,
|
|
67
|
+
* passwd-based on POSIX). `os.homedir()` alone would silently ignore a
|
|
68
|
+
* sandboxed HOME on Windows and land every installer-family test on the real
|
|
69
|
+
* production home (ERR-083 OCC-20261117T190516Z).
|
|
70
|
+
*/
|
|
71
|
+
export function resolveRealUserHome(env = process.env) {
|
|
72
|
+
const home = env.HOME?.trim();
|
|
73
|
+
return home !== undefined && home.length > 0 ? home : os.homedir();
|
|
74
|
+
}
|
|
52
75
|
function failure(input) {
|
|
53
76
|
return { ok: false, ...input };
|
|
54
77
|
}
|
|
@@ -98,10 +121,8 @@ function canonicalizeDeepestExisting(target) {
|
|
|
98
121
|
function productionPaths(realHome, env) {
|
|
99
122
|
// PRI-1165: OPENCLAW_STATE_DIR is OpenClaw's authoritative state dir, so PD's
|
|
100
123
|
// `openclawHome` follows it when set. OPENCLAW_HOME stays as the legacy
|
|
101
|
-
// fallback:
|
|
102
|
-
//
|
|
103
|
-
// their backups/extensions. Precedence:
|
|
104
|
-
// OPENCLAW_STATE_DIR > OPENCLAW_HOME > <realHome>/.openclaw
|
|
124
|
+
// fallback: existing PD installs pass the `.openclaw` directory, and
|
|
125
|
+
// reinterpreting it would move their backups/extensions.
|
|
105
126
|
const stateDirOverride = env[PD_OPENCLAW_STATE_DIR_ENV]?.trim();
|
|
106
127
|
if (stateDirOverride !== undefined && stateDirOverride.length > 0 && !path.isAbsolute(stateDirOverride)) {
|
|
107
128
|
return failure({
|
|
@@ -113,24 +134,30 @@ function productionPaths(realHome, env) {
|
|
|
113
134
|
}
|
|
114
135
|
const openclawOverride = env[PD_OPENCLAW_HOME_ENV]?.trim();
|
|
115
136
|
// No realpath rewrite (existing installs rely on the literal resolved path).
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
const openclawHome = stateDirOverride
|
|
138
|
+
? path.resolve(stateDirOverride)
|
|
139
|
+
: openclawOverride
|
|
140
|
+
? path.resolve(openclawOverride)
|
|
141
|
+
: path.join(realHome, '.openclaw');
|
|
142
|
+
const codexOverride = env[PD_CODEX_HOME_ENV]?.trim();
|
|
143
|
+
const codexHome = codexOverride ? path.resolve(codexOverride) : path.join(realHome, '.codex');
|
|
144
|
+
const workbuddyOverride = env[PD_WORKBUDDY_CONFIG_DIR_ENV]?.trim();
|
|
145
|
+
const workbuddyConfigDir = workbuddyOverride ? path.resolve(workbuddyOverride) : path.join(realHome, '.workbuddy');
|
|
146
|
+
const pdHome = path.join(realHome, '.pd');
|
|
126
147
|
return {
|
|
127
148
|
ok: true,
|
|
128
149
|
mode: 'production',
|
|
129
150
|
homeDir: realHome,
|
|
130
|
-
pdHome
|
|
151
|
+
pdHome,
|
|
152
|
+
runtimeDir: path.join(pdHome, 'runtime'),
|
|
153
|
+
pdRuntimeBackupsDir: path.join(pdHome, 'backups'),
|
|
131
154
|
openclawHome,
|
|
155
|
+
openclawExtensionDir: path.join(openclawHome, 'extensions', 'principles-disciple'),
|
|
132
156
|
consoleConfigDir: path.join(realHome, '.pd-console'),
|
|
133
|
-
codexHome
|
|
157
|
+
codexHome,
|
|
158
|
+
codexWorkspaceDir: path.join(codexHome, PD_HOST_WORKSPACE_DIR_NAME),
|
|
159
|
+
workbuddyConfigDir,
|
|
160
|
+
workbuddyWorkspaceDir: path.join(workbuddyConfigDir, PD_HOST_WORKSPACE_DIR_NAME),
|
|
134
161
|
};
|
|
135
162
|
}
|
|
136
163
|
/**
|
|
@@ -139,7 +166,7 @@ function productionPaths(realHome, env) {
|
|
|
139
166
|
*/
|
|
140
167
|
export function resolvePdHome(options = {}) {
|
|
141
168
|
const env = options.env ?? process.env;
|
|
142
|
-
const realHome = path.resolve(options.homeDir ??
|
|
169
|
+
const realHome = path.resolve(options.homeDir ?? resolveRealUserHome(env));
|
|
143
170
|
const rawRoot = env[PD_EXPERIMENT_ROOT_ENV];
|
|
144
171
|
if (rawRoot === undefined) {
|
|
145
172
|
return productionPaths(realHome, env);
|
|
@@ -196,13 +223,24 @@ export function resolvePdHome(options = {}) {
|
|
|
196
223
|
details: { experimentRoot: declared },
|
|
197
224
|
});
|
|
198
225
|
}
|
|
199
|
-
// The experiment must be DISJOINT from
|
|
200
|
-
//
|
|
201
|
-
//
|
|
226
|
+
// The experiment must be DISJOINT from every default production PD/host
|
|
227
|
+
// control root in both directions. The production roots derive from the
|
|
228
|
+
// RESOLVED real home (options.homeDir ?? the shared HOME-first precedence):
|
|
229
|
+
// an explicit homeDir injection is the production home under test, and the
|
|
230
|
+
// HOME precedence keeps HOME-sandboxed flows self-consistent. Host
|
|
231
|
+
// overrides in this environment are interpreted below as experiment targets
|
|
232
|
+
// and must independently stay inside rootReal; treating them as production
|
|
233
|
+
// paths here would reject the intended launcher configuration.
|
|
234
|
+
const nonEmptyOverride = (name) => {
|
|
235
|
+
const value = env[name]?.trim();
|
|
236
|
+
return value ? value : undefined;
|
|
237
|
+
};
|
|
202
238
|
const productionDirs = [
|
|
203
239
|
['.pd', path.join(realHome, '.pd')],
|
|
204
240
|
['.pd-console', path.join(realHome, '.pd-console')],
|
|
205
241
|
['.openclaw', path.join(realHome, '.openclaw')],
|
|
242
|
+
['.codex', path.join(realHome, '.codex')],
|
|
243
|
+
['.workbuddy', path.join(realHome, '.workbuddy')],
|
|
206
244
|
];
|
|
207
245
|
for (const [label, productionDir] of productionDirs) {
|
|
208
246
|
const productionReal = canonicalizeDeepestExisting(productionDir) ?? path.resolve(productionDir);
|
|
@@ -215,11 +253,60 @@ export function resolvePdHome(options = {}) {
|
|
|
215
253
|
});
|
|
216
254
|
}
|
|
217
255
|
}
|
|
256
|
+
// Resolve host-owned config roots inside the lab. Relative overrides are
|
|
257
|
+
// refused rather than being interpreted against whichever cwd launched PD.
|
|
258
|
+
let codexHome = path.join(rootReal, '.codex');
|
|
259
|
+
const codexOverride = nonEmptyOverride(PD_CODEX_HOME_ENV);
|
|
260
|
+
if (codexOverride) {
|
|
261
|
+
if (!path.isAbsolute(codexOverride)) {
|
|
262
|
+
return failure({
|
|
263
|
+
reason: 'codex_home_not_absolute',
|
|
264
|
+
message: `${PD_CODEX_HOME_ENV} must be an absolute path in experiment mode (got "${codexOverride}").`,
|
|
265
|
+
nextAction: `Unset ${PD_CODEX_HOME_ENV} to use ${codexHome}, or point it inside ${rootReal}.`,
|
|
266
|
+
details: { experimentRoot: rootReal, [PD_CODEX_HOME_ENV]: codexOverride },
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
const overrideReal = canonicalizeDeepestExisting(codexOverride) ?? path.resolve(codexOverride);
|
|
270
|
+
if (!isPathWithinRoot(rootReal, overrideReal)) {
|
|
271
|
+
return failure({
|
|
272
|
+
reason: 'codex_home_outside_experiment',
|
|
273
|
+
message: `${PD_CODEX_HOME_ENV} points outside the experiment root: ${codexOverride} -> ${overrideReal}`,
|
|
274
|
+
nextAction: `Unset ${PD_CODEX_HOME_ENV} to use ${codexHome}, or point it inside ${rootReal}.`,
|
|
275
|
+
details: { experimentRoot: rootReal, [PD_CODEX_HOME_ENV]: codexOverride },
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
codexHome = path.resolve(codexOverride);
|
|
279
|
+
}
|
|
280
|
+
let workbuddyConfigDir = path.join(rootReal, '.workbuddy');
|
|
281
|
+
const workbuddyOverride = nonEmptyOverride(PD_WORKBUDDY_CONFIG_DIR_ENV);
|
|
282
|
+
if (workbuddyOverride) {
|
|
283
|
+
if (!path.isAbsolute(workbuddyOverride)) {
|
|
284
|
+
return failure({
|
|
285
|
+
reason: 'workbuddy_config_dir_not_absolute',
|
|
286
|
+
message: `${PD_WORKBUDDY_CONFIG_DIR_ENV} must be an absolute path in experiment mode (got "${workbuddyOverride}").`,
|
|
287
|
+
nextAction: `Unset ${PD_WORKBUDDY_CONFIG_DIR_ENV} to use ${workbuddyConfigDir}, or point it inside ${rootReal}.`,
|
|
288
|
+
details: { experimentRoot: rootReal, [PD_WORKBUDDY_CONFIG_DIR_ENV]: workbuddyOverride },
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
const overrideReal = canonicalizeDeepestExisting(workbuddyOverride) ?? path.resolve(workbuddyOverride);
|
|
292
|
+
if (!isPathWithinRoot(rootReal, overrideReal)) {
|
|
293
|
+
return failure({
|
|
294
|
+
reason: 'workbuddy_config_dir_outside_experiment',
|
|
295
|
+
message: `${PD_WORKBUDDY_CONFIG_DIR_ENV} points outside the experiment root: ${workbuddyOverride} -> ${overrideReal}`,
|
|
296
|
+
nextAction: `Unset ${PD_WORKBUDDY_CONFIG_DIR_ENV} to use ${workbuddyConfigDir}, or point it inside ${rootReal}.`,
|
|
297
|
+
details: { experimentRoot: rootReal, [PD_WORKBUDDY_CONFIG_DIR_ENV]: workbuddyOverride },
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
workbuddyConfigDir = path.resolve(workbuddyOverride);
|
|
301
|
+
}
|
|
218
302
|
const experimentPaths = [
|
|
219
303
|
['pdHome', path.join(rootReal, '.pd')],
|
|
220
304
|
['openclawHome', path.join(rootReal, '.openclaw')],
|
|
221
305
|
['consoleConfigDir', path.join(rootReal, '.pd-console')],
|
|
222
|
-
['codexHome',
|
|
306
|
+
['codexHome', codexHome],
|
|
307
|
+
['codexWorkspaceDir', path.join(codexHome, PD_HOST_WORKSPACE_DIR_NAME)],
|
|
308
|
+
['workbuddyConfigDir', workbuddyConfigDir],
|
|
309
|
+
['workbuddyWorkspaceDir', path.join(workbuddyConfigDir, PD_HOST_WORKSPACE_DIR_NAME)],
|
|
223
310
|
];
|
|
224
311
|
for (const [label, candidate] of experimentPaths) {
|
|
225
312
|
// A pre-existing link at (or above) a derived path is the escape route:
|
|
@@ -276,14 +363,42 @@ export function resolvePdHome(options = {}) {
|
|
|
276
363
|
openclawHome = path.resolve(openclawOverride);
|
|
277
364
|
}
|
|
278
365
|
}
|
|
366
|
+
const pdHome = path.join(rootReal, '.pd');
|
|
367
|
+
// Second boundary pass over the DERIVED leaf directories. The first pass
|
|
368
|
+
// checks the config roots themselves; these leaves sit below them, so a
|
|
369
|
+
// normal `<root>/.pd` with a junctioned `<root>/.pd/backups` (pointing at the
|
|
370
|
+
// production backups) would pass the first pass while the returned paths
|
|
371
|
+
// actually land outside the root. Same link-aware containment as above.
|
|
372
|
+
const derivedPaths = [
|
|
373
|
+
['runtimeDir', path.join(pdHome, 'runtime')],
|
|
374
|
+
['pdRuntimeBackupsDir', path.join(pdHome, 'backups')],
|
|
375
|
+
['openclawExtensionDir', path.join(openclawHome, 'extensions', 'principles-disciple')],
|
|
376
|
+
];
|
|
377
|
+
for (const [label, candidate] of derivedPaths) {
|
|
378
|
+
const candidateReal = canonicalizeDeepestExisting(candidate);
|
|
379
|
+
if (candidateReal === null || !isPathWithinRoot(rootReal, candidateReal)) {
|
|
380
|
+
return failure({
|
|
381
|
+
reason: 'experiment_path_escapes_root',
|
|
382
|
+
message: `${label} resolves outside the experiment root: ${candidate} -> ${candidateReal ?? 'unresolvable'}`,
|
|
383
|
+
nextAction: 'Remove the junction/symlink at that path (or point it inside the root) and retry.',
|
|
384
|
+
details: { experimentRoot: rootReal, path: candidate, resolved: candidateReal ?? '' },
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
279
388
|
return {
|
|
280
389
|
ok: true,
|
|
281
390
|
mode: 'experiment',
|
|
282
391
|
homeDir: rootReal,
|
|
283
|
-
pdHome
|
|
392
|
+
pdHome,
|
|
393
|
+
runtimeDir: path.join(pdHome, 'runtime'),
|
|
394
|
+
pdRuntimeBackupsDir: path.join(pdHome, 'backups'),
|
|
284
395
|
openclawHome,
|
|
396
|
+
openclawExtensionDir: path.join(openclawHome, 'extensions', 'principles-disciple'),
|
|
285
397
|
consoleConfigDir: path.join(rootReal, '.pd-console'),
|
|
286
|
-
codexHome
|
|
398
|
+
codexHome,
|
|
399
|
+
codexWorkspaceDir: path.join(codexHome, PD_HOST_WORKSPACE_DIR_NAME),
|
|
400
|
+
workbuddyConfigDir,
|
|
401
|
+
workbuddyWorkspaceDir: path.join(workbuddyConfigDir, PD_HOST_WORKSPACE_DIR_NAME),
|
|
287
402
|
experimentRoot: rootReal,
|
|
288
403
|
};
|
|
289
404
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-principles-disciple",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.154.0",
|
|
4
4
|
"description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@earendil-works/pi-agent-core": "1.2.0",
|
|
66
66
|
"@earendil-works/pi-ai": "1.4.0",
|
|
67
|
-
"@principles/install-layout": "^0.
|
|
67
|
+
"@principles/install-layout": "^0.9.0",
|
|
68
68
|
"@sinclair/typebox": "^0.34.52",
|
|
69
69
|
"@tufjs/models": "3.0.1",
|
|
70
70
|
"@inquirer/prompts": "^8.7.2",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"directory": "packages/create-principles-disciple"
|
|
101
101
|
},
|
|
102
102
|
"pd": {
|
|
103
|
-
"bundledPluginVersion": "
|
|
103
|
+
"bundledPluginVersion": "4.1.8"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "95de4c633aedd4d588286c665baf3af816f6250a"
|
|
106
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candidate.d.ts","sourceRoot":"","sources":["../../src/commands/candidate.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,mBAAmB,EA6BpB,MAAM,0BAA0B,CAAC;AAiBlC,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,qBAAqB;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAoED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,oCAAoC,CACxD,YAAY,EAAE,mBAAmB,EACjC,SAAS,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB;AAgDD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CnF;AAID,UAAU,2BAA2B;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"candidate.d.ts","sourceRoot":"","sources":["../../src/commands/candidate.ts"],"names":[],"mappings":"AAgBA,OAAO,EACL,mBAAmB,EA6BpB,MAAM,0BAA0B,CAAC;AAiBlC,UAAU,oBAAoB;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,qBAAqB;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAoED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,oCAAoC,CACxD,YAAY,EAAE,mBAAmB,EACjC,SAAS,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACnD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB;AAgDD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0CnF;AAID,UAAU,2BAA2B;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AA4BD,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CA2QjG;AAKD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDnF;AAkqBD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4LvF;AAID,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,kFAAkF;IAClF,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC5B,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyPvF;AAID;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqDrF;AAID;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiIvF;AAID,UAAU,wBAAwB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAiFD,wBAAsB,sCAAsC,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2W1G;AAID,UAAU,qBAAqB;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+CrF"}
|