create-principles-disciple 1.153.3 → 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 +153 -9
- package/console/dist/web/assets/app.js +41 -37
- package/console/dist/web/assets/intent-reflection.webp +3 -0
- 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/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +137 -9
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +627 -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.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +51 -15
- 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 +627 -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 +51 -15
- 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
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
import { execFileSync } from 'child_process';
|
|
13
13
|
import * as fs from 'fs';
|
|
14
14
|
import * as path from 'path';
|
|
15
|
-
import * as os from 'os';
|
|
16
15
|
import * as net from 'net';
|
|
17
|
-
import {
|
|
16
|
+
import { findForeignWorkspaceOwner } from './host-workspace-ownership.js';
|
|
18
17
|
import { errnoCode } from './config-file-io.js';
|
|
18
|
+
import { resolvePdHome } from '@principles/install-layout';
|
|
19
19
|
const IS_WIN32 = process.platform === 'win32';
|
|
20
20
|
/** 探测超时:卡死的 .cmd shim / 挂起的二进制不应挂住安装器(rc-9 降级)。 */
|
|
21
21
|
const DETECT_TIMEOUT_MS = 5000;
|
|
@@ -96,8 +96,8 @@ export function checkEnvironment() {
|
|
|
96
96
|
return result;
|
|
97
97
|
}
|
|
98
98
|
/** The initialized Codex workspace used by `$pd-control setup` (`locateWorkspace`). */
|
|
99
|
-
function codexWorkspaceCandidates(
|
|
100
|
-
const candidates = [
|
|
99
|
+
function codexWorkspaceCandidates(hostRoots, workspaceDir, cwd) {
|
|
100
|
+
const candidates = [workspaceDir];
|
|
101
101
|
// A project with `.pd/config.yaml` is an initialized workspace and wins over
|
|
102
102
|
// the bare cwd, matching the plugin's own locateWorkspace order.
|
|
103
103
|
let current = cwd;
|
|
@@ -113,40 +113,83 @@ function codexWorkspaceCandidates(homeDir, codexHome, cwd) {
|
|
|
113
113
|
}
|
|
114
114
|
candidates.push(cwd);
|
|
115
115
|
// Never default Codex to another PD host's owned workspace, even when the
|
|
116
|
-
// process happens to run inside it
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
// process happens to run inside it — INCLUDING a non-default workspace that
|
|
117
|
+
// host formally declared (PRI-1247 reopen: defaults-only missed the incident
|
|
118
|
+
// target `D:\.openclaw\workspace`). Directory SOURCES are the #2699 PD-Home
|
|
119
|
+
// roots authority only; the verdict adds declarations/payload bindings and
|
|
120
|
+
// multi-owner reporting, never a second layout source.
|
|
121
|
+
return candidates.filter((candidate) => findForeignWorkspaceOwner('codex', candidate, {
|
|
122
|
+
...hostRoots,
|
|
120
123
|
platform: process.platform,
|
|
121
|
-
}) ===
|
|
124
|
+
}).owners.length === 0);
|
|
122
125
|
}
|
|
123
126
|
/**
|
|
124
127
|
* 检测工作区。
|
|
125
128
|
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
+
* Each host uses its own resolved PD governance workspace. Codex may fall back
|
|
130
|
+
* to a nearest initialized project workspace; WorkBuddy never inherits the
|
|
131
|
+
* OpenClaw workspace candidates.
|
|
132
|
+
*/
|
|
133
|
+
/**
|
|
134
|
+
* Derive the host config roots from the BASE PdHomePaths fields only
|
|
135
|
+
* (pdHome/homeDir/openclawHome/codexHome — present since install-layout 0.8.3,
|
|
136
|
+
* which the packaged installer resolves from the npm registry — see
|
|
137
|
+
* mcp-server-layout-compat.ts and Devin review #2699-0003). The derivations
|
|
138
|
+
* mirror resolvePdHome's own computations, so the two stay semantically pinned;
|
|
139
|
+
* when install-layout publishes the newer fields the consumers can switch back.
|
|
129
140
|
*/
|
|
141
|
+
function deriveHostRoots(homePaths, env) {
|
|
142
|
+
const { homeDir, codexHome: resolvedCodexHome } = homePaths;
|
|
143
|
+
const codexHome = resolvedCodexHome ?? path.join(homeDir, '.codex');
|
|
144
|
+
const workbuddyOverride = env.WORKBUDDY_CONFIG_DIR?.trim();
|
|
145
|
+
const workbuddyConfigDir = workbuddyOverride !== undefined && workbuddyOverride.length > 0
|
|
146
|
+
? path.resolve(workbuddyOverride)
|
|
147
|
+
: path.join(homeDir, '.workbuddy');
|
|
148
|
+
return {
|
|
149
|
+
homeDir,
|
|
150
|
+
openclawHome: homePaths.openclawHome,
|
|
151
|
+
codexHome,
|
|
152
|
+
codexWorkspaceDir: path.join(codexHome, 'pd-workspace'),
|
|
153
|
+
workbuddyConfigDir,
|
|
154
|
+
workbuddyWorkspaceDir: path.join(workbuddyConfigDir, 'pd-workspace'),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
130
157
|
export function detectWorkspace(options = {}) {
|
|
131
|
-
const homeDir = options.homeDir ?? os.homedir();
|
|
132
158
|
const host = options.host ?? 'openclaw';
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
159
|
+
const env = { ...(options.env ?? process.env) };
|
|
160
|
+
if (options.codexHome !== undefined)
|
|
161
|
+
env.CODEX_HOME = options.codexHome;
|
|
162
|
+
// No explicit homeDir injection → let the shared resolver pick the default
|
|
163
|
+
// (HOME-first). Pinning os.homedir() here would bypass the shared HOME
|
|
164
|
+
// precedence and diverge from the installer's own write paths on hosts where
|
|
165
|
+
// HOME ≠ os.homedir() (review N2-).
|
|
166
|
+
const homePaths = resolvePdHome(options.homeDir !== undefined ? { homeDir: options.homeDir, env } : { env });
|
|
167
|
+
if (!homePaths.ok) {
|
|
168
|
+
throw new Error(`PD home resolution refused (${homePaths.reason}): ${homePaths.message} Next action: ${homePaths.nextAction}`);
|
|
169
|
+
}
|
|
170
|
+
const hostRoots = deriveHostRoots(homePaths, env);
|
|
171
|
+
const candidates = [];
|
|
172
|
+
if (host === 'codex') {
|
|
173
|
+
candidates.push(...codexWorkspaceCandidates({
|
|
174
|
+
homeDir: hostRoots.homeDir,
|
|
175
|
+
codexHome: hostRoots.codexHome,
|
|
176
|
+
openclawHome: hostRoots.openclawHome,
|
|
177
|
+
workbuddyConfigDir: hostRoots.workbuddyConfigDir,
|
|
178
|
+
}, hostRoots.codexWorkspaceDir, options.cwd ?? process.cwd()));
|
|
179
|
+
}
|
|
180
|
+
else if (host === 'workbuddy') {
|
|
181
|
+
candidates.push(hostRoots.workbuddyWorkspaceDir);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// OpenClaw owns its default workspace under the active OpenClaw state dir.
|
|
185
|
+
if (typeof env.OPENCLAW_WORKSPACE === 'string' && env.OPENCLAW_WORKSPACE.trim().length > 0) {
|
|
186
|
+
candidates.push(env.OPENCLAW_WORKSPACE);
|
|
144
187
|
}
|
|
145
|
-
if (
|
|
146
|
-
candidates.push(
|
|
188
|
+
if (typeof env.PD_WORKSPACE_DIR === 'string' && env.PD_WORKSPACE_DIR.trim().length > 0) {
|
|
189
|
+
candidates.push(env.PD_WORKSPACE_DIR);
|
|
147
190
|
}
|
|
148
|
-
candidates.push(path.join(homeDir, 'clawd'));
|
|
149
|
-
candidates.push(path.join(
|
|
191
|
+
candidates.push(path.join(hostRoots.homeDir, 'clawd'));
|
|
192
|
+
candidates.push(path.join(hostRoots.openclawHome, 'workspace'));
|
|
150
193
|
}
|
|
151
194
|
// 核心文件列表(用于检测是否已安装)
|
|
152
195
|
const CORE_FILES = [
|
|
@@ -182,8 +225,10 @@ export function detectWorkspace(options = {}) {
|
|
|
182
225
|
}
|
|
183
226
|
// Codex first install defaults to ITS OWN user workspace; OpenClaw keeps ~/clawd.
|
|
184
227
|
const defaultPath = host === 'codex'
|
|
185
|
-
?
|
|
186
|
-
:
|
|
228
|
+
? hostRoots.codexWorkspaceDir
|
|
229
|
+
: host === 'workbuddy'
|
|
230
|
+
? hostRoots.workbuddyWorkspaceDir
|
|
231
|
+
: path.join(hostRoots.homeDir, 'clawd');
|
|
187
232
|
return {
|
|
188
233
|
detectedPath: defaultPath,
|
|
189
234
|
exists: false,
|
|
@@ -195,14 +240,26 @@ export function detectWorkspace(options = {}) {
|
|
|
195
240
|
/**
|
|
196
241
|
* 获取 OpenClaw 配置目录
|
|
197
242
|
*/
|
|
198
|
-
export function getOpenClawConfigDir() {
|
|
199
|
-
|
|
243
|
+
export function getOpenClawConfigDir(homeDir, env = process.env) {
|
|
244
|
+
const homePaths = resolvePdHome(homeDir !== undefined ? { homeDir, env } : { env });
|
|
245
|
+
if (!homePaths.ok) {
|
|
246
|
+
throw new Error(`PD home resolution refused (${homePaths.reason}): ${homePaths.message} Next action: ${homePaths.nextAction}`);
|
|
247
|
+
}
|
|
248
|
+
// Derived from the base openclawHome field (registry-surface compatibility).
|
|
249
|
+
return homePaths.openclawHome;
|
|
200
250
|
}
|
|
201
251
|
/**
|
|
202
252
|
* 获取插件扩展目录
|
|
203
253
|
*/
|
|
204
|
-
export function getPluginExtDir() {
|
|
205
|
-
|
|
254
|
+
export function getPluginExtDir(homeDir, env = process.env) {
|
|
255
|
+
const homePaths = resolvePdHome(homeDir !== undefined ? { homeDir, env } : { env });
|
|
256
|
+
if (!homePaths.ok) {
|
|
257
|
+
throw new Error(`PD home resolution refused (${homePaths.reason}): ${homePaths.message} Next action: ${homePaths.nextAction}`);
|
|
258
|
+
}
|
|
259
|
+
// Derived from the base openclawHome field (registry-surface compatibility,
|
|
260
|
+
// see deriveHostRoots above) — identical to the extension-dir computation
|
|
261
|
+
// resolvePdHome itself performs.
|
|
262
|
+
return path.join(homePaths.openclawHome, 'extensions', 'principles-disciple');
|
|
206
263
|
}
|
|
207
264
|
function readOpenClawPort() {
|
|
208
265
|
const configPath = path.join(getOpenClawConfigDir(), 'openclaw.json');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
1
2
|
import * as path from 'node:path';
|
|
2
3
|
import * as installLayout from '@principles/install-layout';
|
|
3
4
|
const BINDING_HOSTS = ['openclaw', 'codex', 'workbuddy'];
|
|
@@ -6,13 +7,19 @@ function hostOwnedWorkspaces(host, options) {
|
|
|
6
7
|
const codexHome = options.codexHome !== undefined
|
|
7
8
|
? path.resolve(options.codexHome)
|
|
8
9
|
: path.join(home, '.codex');
|
|
10
|
+
const openclawHome = options.openclawHome !== undefined
|
|
11
|
+
? path.resolve(options.openclawHome)
|
|
12
|
+
: path.join(home, '.openclaw');
|
|
13
|
+
const workbuddyConfigDir = options.workbuddyConfigDir !== undefined
|
|
14
|
+
? path.resolve(options.workbuddyConfigDir)
|
|
15
|
+
: path.join(home, '.workbuddy');
|
|
9
16
|
switch (host) {
|
|
10
17
|
case 'openclaw':
|
|
11
|
-
return [path.join(home, 'clawd'), path.join(
|
|
18
|
+
return [path.join(home, 'clawd'), path.join(openclawHome, 'workspace')];
|
|
12
19
|
case 'codex':
|
|
13
20
|
return [path.join(codexHome, 'pd-workspace')];
|
|
14
21
|
case 'workbuddy':
|
|
15
|
-
return [path.join(
|
|
22
|
+
return [path.join(workbuddyConfigDir, 'pd-workspace')];
|
|
16
23
|
}
|
|
17
24
|
}
|
|
18
25
|
function isSameOrInside(parent, child, platform) {
|
|
@@ -66,4 +73,148 @@ export function findForeignWorkspaceHost(host, workspaceDir, options) {
|
|
|
66
73
|
return shared(host, workspaceDir, options);
|
|
67
74
|
return findForeignWorkspaceHostFallback(host, workspaceDir, options);
|
|
68
75
|
}
|
|
76
|
+
function isPlainRecord(value) {
|
|
77
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
78
|
+
}
|
|
79
|
+
const fsReaders = {
|
|
80
|
+
readJson(file) {
|
|
81
|
+
try {
|
|
82
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
83
|
+
// rc-1/rc-2: the type guard narrows without an `as` cast.
|
|
84
|
+
return isPlainRecord(parsed) ? parsed : undefined;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
listDir(dir) {
|
|
91
|
+
try {
|
|
92
|
+
return fs.readdirSync(dir);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
realpath(target) {
|
|
99
|
+
try {
|
|
100
|
+
return fs.realpathSync.native(target);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
function readAbsoluteWorkspaceField(readers, file, field) {
|
|
108
|
+
const parsed = readers.readJson(file);
|
|
109
|
+
if (parsed === undefined)
|
|
110
|
+
return undefined;
|
|
111
|
+
const value = parsed[field];
|
|
112
|
+
if (typeof value !== 'string' || value.trim().length === 0)
|
|
113
|
+
return undefined;
|
|
114
|
+
if (!path.isAbsolute(value.trim()))
|
|
115
|
+
return undefined;
|
|
116
|
+
return path.resolve(value.trim());
|
|
117
|
+
}
|
|
118
|
+
function collectClaimsFallback(options, readers) {
|
|
119
|
+
const home = path.resolve(options.homeDir);
|
|
120
|
+
const codexHome = options.codexHome !== undefined
|
|
121
|
+
? path.resolve(options.codexHome)
|
|
122
|
+
: path.join(home, '.codex');
|
|
123
|
+
// Same actual-root rule as the shared collector: the declaration lives
|
|
124
|
+
// under openclawHome (OPENCLAW_STATE_DIR/OPENCLAW_HOME when set), not a
|
|
125
|
+
// fixed `<home>/.openclaw` — the launcher reads the actual root, so a
|
|
126
|
+
// fixed default would let this installer write a binding the launcher
|
|
127
|
+
// then refuses (review 2026-11-18).
|
|
128
|
+
const openclawHome = options.openclawHome !== undefined
|
|
129
|
+
? path.resolve(options.openclawHome)
|
|
130
|
+
: path.join(home, '.openclaw');
|
|
131
|
+
const claims = [];
|
|
132
|
+
for (const host of BINDING_HOSTS) {
|
|
133
|
+
for (const dir of hostOwnedWorkspaces(host, options)) {
|
|
134
|
+
claims.push({ host, workspaceDir: dir, via: 'default', source: 'default' });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const file of [path.join(openclawHome, 'principles-disciple.json'), path.join(home, '.principles', 'principles-disciple.json')]) {
|
|
138
|
+
const declared = readAbsoluteWorkspaceField(readers, file, 'workspace');
|
|
139
|
+
if (declared !== undefined) {
|
|
140
|
+
claims.push({ host: 'openclaw', workspaceDir: declared, via: 'host_declaration', source: file });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const dataRoot = path.join(codexHome, 'plugins', 'data');
|
|
144
|
+
for (const entry of readers.listDir(dataRoot) ?? []) {
|
|
145
|
+
if (typeof entry !== 'string' || !entry.startsWith('principles-disciple-'))
|
|
146
|
+
continue;
|
|
147
|
+
const binding = path.join(dataRoot, entry, 'mcp-binding.json');
|
|
148
|
+
const bound = readAbsoluteWorkspaceField(readers, binding, 'workspaceDir');
|
|
149
|
+
if (bound !== undefined) {
|
|
150
|
+
claims.push({ host: 'codex', workspaceDir: bound, via: 'payload_binding', source: binding });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const wbBinding = path.join(home, '.pd', 'workbuddy-marketplace', 'principles-disciple', 'mcp-binding.json');
|
|
154
|
+
const wbBound = readAbsoluteWorkspaceField(readers, wbBinding, 'workspaceDir');
|
|
155
|
+
if (wbBound !== undefined) {
|
|
156
|
+
claims.push({ host: 'workbuddy', workspaceDir: wbBound, via: 'payload_binding', source: wbBinding });
|
|
157
|
+
}
|
|
158
|
+
return claims;
|
|
159
|
+
}
|
|
160
|
+
function workspaceIdentityFallback(dir, readers, platform) {
|
|
161
|
+
const real = readers.realpath(dir);
|
|
162
|
+
const resolved = real !== undefined ? real : path.resolve(dir);
|
|
163
|
+
return platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Declaration-aware fallback mirroring `findForeignWorkspaceOwner` in
|
|
167
|
+
* `@principles/install-layout` (PRI-1247 reopen): defaults + the hosts' FORMAL
|
|
168
|
+
* declarations (`principles-disciple.json`) + payload bindings, compared by
|
|
169
|
+
* final directory identity (realpath, case-folded on win32). A parity test
|
|
170
|
+
* pins both sides together.
|
|
171
|
+
*/
|
|
172
|
+
export function findForeignWorkspaceOwnerFallback(host, workspaceDir, options) {
|
|
173
|
+
if (workspaceDir.trim().length === 0)
|
|
174
|
+
return { owners: [], via: null };
|
|
175
|
+
const target = workspaceIdentityFallback(workspaceDir, fsReaders, options.platform);
|
|
176
|
+
const owners = [];
|
|
177
|
+
let via = null;
|
|
178
|
+
for (const claim of collectClaimsFallback(options, fsReaders)) {
|
|
179
|
+
if (claim.host === host)
|
|
180
|
+
continue;
|
|
181
|
+
if (claim.workspaceDir.trim().length === 0)
|
|
182
|
+
continue;
|
|
183
|
+
const claimIdentity = workspaceIdentityFallback(claim.workspaceDir, fsReaders, options.platform);
|
|
184
|
+
const same = claimIdentity === target;
|
|
185
|
+
const relative = path.relative(claimIdentity, target);
|
|
186
|
+
const insideIdentity = !same && relative !== '' && !path.isAbsolute(relative)
|
|
187
|
+
&& relative !== '..' && !relative.startsWith('..' + path.sep);
|
|
188
|
+
const insideLexical = !same && isSameOrInside(claim.workspaceDir, workspaceDir, options.platform);
|
|
189
|
+
if (same || insideIdentity || insideLexical) {
|
|
190
|
+
if (!owners.includes(claim.host))
|
|
191
|
+
owners.push(claim.host);
|
|
192
|
+
via ??= claim.via;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return { owners, via };
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Resolve the declaration-aware ownership verdict: the shared install-layout
|
|
199
|
+
* implementation when the resolved package provides it, otherwise the
|
|
200
|
+
* byte-equivalent local fallback. This is the ONE judgment the installer, the
|
|
201
|
+
* Codex binding health check, migration and pd-setup must reuse — default-dir
|
|
202
|
+
* enumeration alone accepts a formally declared NON-DEFAULT workspace of
|
|
203
|
+
* another host (the PRI-1247 incident's target).
|
|
204
|
+
*/
|
|
205
|
+
export function findForeignWorkspaceOwner(host, workspaceDir, options) {
|
|
206
|
+
// PRI-669 shape: probe the namespace, never a named import — the installer's
|
|
207
|
+
// top-level graph loads against the CURRENT registry install-layout. The
|
|
208
|
+
// `unknown` hop keeps the structural probe honest on both sides (rc-2).
|
|
209
|
+
const shared = installLayout
|
|
210
|
+
.findForeignWorkspaceOwner;
|
|
211
|
+
if (typeof shared === 'function') {
|
|
212
|
+
const verdict = shared(host, workspaceDir, options);
|
|
213
|
+
return {
|
|
214
|
+
owners: Array.isArray(verdict.owners) ? verdict.owners : [],
|
|
215
|
+
via: verdict.via ?? null,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return findForeignWorkspaceOwnerFallback(host, workspaceDir, options);
|
|
219
|
+
}
|
|
69
220
|
//# sourceMappingURL=host-workspace-ownership.js.map
|
|
@@ -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": {
|
|
@@ -100,6 +100,6 @@
|
|
|
100
100
|
"directory": "packages/create-principles-disciple"
|
|
101
101
|
},
|
|
102
102
|
"pd": {
|
|
103
|
-
"bundledPluginVersion": "
|
|
103
|
+
"bundledPluginVersion": "4.1.8"
|
|
104
104
|
}
|
|
105
105
|
}
|
|
@@ -14,4 +14,4 @@ export { WORKBUDDY_TOOL_SEMANTICS, WORKBUDDY_TOOL_SEMANTIC_MAPPINGS, } from './t
|
|
|
14
14
|
export { recordWorkbuddyPromptDeliveryEvidence, recordWorkbuddyDenyEvidence, workbuddyCapabilityDeclarations, WORKBUDDY_EVIDENCE_ADAPTER_VERSION, } from './workbuddy-evidence-recorder.js';
|
|
15
15
|
export { processWorkbuddyHookInvocation, annotateContextWarnings, type WorkBuddyPdHookResult, } from './pd-hook.js';
|
|
16
16
|
export { runWorkbuddyWorkspaceWorkerCycle, type WorkbuddyWorkerCycleResult, type WorkbuddyWorkerCycleOptions, type WorkbuddyWorkerCycleStepReport, type WorkbuddyWorkerMode, } from './worker/workspace-worker.js';
|
|
17
|
-
export { encodeWorkbuddyCwd, deriveWorkbuddyTranscriptPath, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot, decodeWorkbuddyTranscriptWindow, createWorkbuddyTranscriptSource, WORKBUDDY_SINGLE_SESSION_ALERT_BYTES, type WorkbuddyTranscriptFileIdentity, type WorkbuddyTranscriptPathValidation, type DecodedWorkbuddyDelta, type DecodeWorkbuddyWindowInput, type WorkbuddyTranscriptSourceContext, ingestWorkbuddyConversation, workbuddyIngestionHints, catchUpWorkbuddyIngestion, locateWorkbuddyTranscriptBySessionIdentity, type WorkbuddyIngestionOptions, type WorkbuddyIngestionOutcome, type WorkbuddyCatchUpOptions, type WorkbuddyCatchUpResult, } from './ingestion/index.js';
|
|
17
|
+
export { encodeWorkbuddyCwd, deriveWorkbuddyTranscriptPath, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot, resolveWorkbuddyProjectsRoot, decodeWorkbuddyTranscriptWindow, createWorkbuddyTranscriptSource, WORKBUDDY_SINGLE_SESSION_ALERT_BYTES, type WorkbuddyTranscriptFileIdentity, type WorkbuddyTranscriptPathValidation, type DecodedWorkbuddyDelta, type DecodeWorkbuddyWindowInput, type WorkbuddyTranscriptSourceContext, ingestWorkbuddyConversation, workbuddyIngestionHints, catchUpWorkbuddyIngestion, locateWorkbuddyTranscriptBySessionIdentity, type WorkbuddyIngestionOptions, type WorkbuddyIngestionOutcome, type WorkbuddyCatchUpOptions, type WorkbuddyCatchUpResult, } from './ingestion/index.js';
|
|
@@ -14,4 +14,4 @@ export { WORKBUDDY_TOOL_SEMANTICS, WORKBUDDY_TOOL_SEMANTIC_MAPPINGS, } from './t
|
|
|
14
14
|
export { recordWorkbuddyPromptDeliveryEvidence, recordWorkbuddyDenyEvidence, workbuddyCapabilityDeclarations, WORKBUDDY_EVIDENCE_ADAPTER_VERSION, } from './workbuddy-evidence-recorder.js';
|
|
15
15
|
export { processWorkbuddyHookInvocation, annotateContextWarnings, } from './pd-hook.js';
|
|
16
16
|
export { runWorkbuddyWorkspaceWorkerCycle, } from './worker/workspace-worker.js';
|
|
17
|
-
export { encodeWorkbuddyCwd, deriveWorkbuddyTranscriptPath, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot, decodeWorkbuddyTranscriptWindow, createWorkbuddyTranscriptSource, WORKBUDDY_SINGLE_SESSION_ALERT_BYTES, ingestWorkbuddyConversation, workbuddyIngestionHints, catchUpWorkbuddyIngestion, locateWorkbuddyTranscriptBySessionIdentity, } from './ingestion/index.js';
|
|
17
|
+
export { encodeWorkbuddyCwd, deriveWorkbuddyTranscriptPath, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot, resolveWorkbuddyProjectsRoot, decodeWorkbuddyTranscriptWindow, createWorkbuddyTranscriptSource, WORKBUDDY_SINGLE_SESSION_ALERT_BYTES, ingestWorkbuddyConversation, workbuddyIngestionHints, catchUpWorkbuddyIngestion, locateWorkbuddyTranscriptBySessionIdentity, } from './ingestion/index.js';
|
|
@@ -22,11 +22,10 @@
|
|
|
22
22
|
* change, no second source of truth — checkpoints stay the authority.
|
|
23
23
|
*/
|
|
24
24
|
import fs from 'node:fs';
|
|
25
|
-
import os from 'node:os';
|
|
26
25
|
import path from 'node:path';
|
|
27
26
|
import { deferGovernanceCheckpoint, listGovernanceCheckpoints, readConversationIngestionConsent } from '@principles/host-runtime';
|
|
28
27
|
import { ingestWorkbuddyConversation } from './ingestion.js';
|
|
29
|
-
import { validateWorkbuddyTranscriptPath, workbuddyProjectsRoot } from './transcript-path.js';
|
|
28
|
+
import { resolveWorkbuddyProjectsRoot, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot } from './transcript-path.js';
|
|
30
29
|
const DEFAULT_MAX_ROLLOUTS = 8;
|
|
31
30
|
/** Mirrors the locator's main-session file-name contract; refuse odd identities. */
|
|
32
31
|
const SESSION_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
@@ -109,7 +108,20 @@ export function catchUpWorkbuddyIngestion(options) {
|
|
|
109
108
|
examined: 0, ingested: 0, warnings: [],
|
|
110
109
|
};
|
|
111
110
|
}
|
|
112
|
-
|
|
111
|
+
// An explicit home (worker env / test injection) keeps the historical
|
|
112
|
+
// `<home>/.workbuddy/projects` derivation; the default follows the shared
|
|
113
|
+
// PD Home authority so an experiment never reads the production WorkBuddy
|
|
114
|
+
// transcript tree (rc-9: structured degradation, never a silent fallback).
|
|
115
|
+
const projectsRootResolution = options.home !== undefined
|
|
116
|
+
? { ok: true, root: workbuddyProjectsRoot(options.home) }
|
|
117
|
+
: resolveWorkbuddyProjectsRoot();
|
|
118
|
+
if (!projectsRootResolution.ok) {
|
|
119
|
+
return {
|
|
120
|
+
status: 'degraded', reason: projectsRootResolution.reason, nextAction: projectsRootResolution.nextAction,
|
|
121
|
+
examined: 0, ingested: 0, warnings: [],
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const projectsRoot = projectsRootResolution.root;
|
|
113
125
|
const limit = Math.max(1, Math.min(options.maxRollouts ?? DEFAULT_MAX_ROLLOUTS, 32));
|
|
114
126
|
const checkpoints = listed.checkpoints.slice(0, limit);
|
|
115
127
|
let ingested = 0;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* TranscriptSourceAdapter the shared host-runtime pipeline drives.
|
|
7
7
|
*/
|
|
8
8
|
export { encodeWorkbuddyCwd } from './encode-cwd.js';
|
|
9
|
-
export { deriveWorkbuddyTranscriptPath, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot, type WorkbuddyTranscriptFileIdentity, type WorkbuddyTranscriptPathValidation, } from './transcript-path.js';
|
|
9
|
+
export { deriveWorkbuddyTranscriptPath, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot, resolveWorkbuddyProjectsRoot, type WorkbuddyTranscriptFileIdentity, type WorkbuddyTranscriptPathValidation, } from './transcript-path.js';
|
|
10
10
|
export { decodeWorkbuddyTranscriptWindow, type DecodedWorkbuddyDelta, type DecodeWorkbuddyWindowInput, } from './transcript-decoder.js';
|
|
11
11
|
export { createWorkbuddyTranscriptSource, WORKBUDDY_SINGLE_SESSION_ALERT_BYTES, type WorkbuddyTranscriptSourceContext, } from './transcript-source.js';
|
|
12
12
|
export { ingestWorkbuddyConversation, workbuddyIngestionHints, type WorkbuddyIngestionOptions, type WorkbuddyIngestionOutcome, } from './ingestion.js';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* TranscriptSourceAdapter the shared host-runtime pipeline drives.
|
|
7
7
|
*/
|
|
8
8
|
export { encodeWorkbuddyCwd } from './encode-cwd.js';
|
|
9
|
-
export { deriveWorkbuddyTranscriptPath, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot, } from './transcript-path.js';
|
|
9
|
+
export { deriveWorkbuddyTranscriptPath, validateWorkbuddyTranscriptPath, workbuddyProjectsRoot, resolveWorkbuddyProjectsRoot, } from './transcript-path.js';
|
|
10
10
|
export { decodeWorkbuddyTranscriptWindow, } from './transcript-decoder.js';
|
|
11
11
|
export { createWorkbuddyTranscriptSource, WORKBUDDY_SINGLE_SESSION_ALERT_BYTES, } from './transcript-source.js';
|
|
12
12
|
export { ingestWorkbuddyConversation, workbuddyIngestionHints, } from './ingestion.js';
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkBuddy conversation-ingestion orchestrator (PRI-1171 P2, ticket ⑤).
|
|
3
|
+
*
|
|
4
|
+
* Connects the EXISTING pieces — the unified host-runtime pipeline, the
|
|
5
|
+
* WorkBuddy TranscriptSourceAdapter from ticket ④, the v3 consent ledger and
|
|
6
|
+
* the workspace feature flags — without introducing a new subsystem. The hook
|
|
7
|
+
* calls `ingestWorkbuddyConversation` on `turn_complete`; the worker calls the
|
|
8
|
+
* catch-up sibling. Both go through this same gate ordering.
|
|
9
|
+
*
|
|
10
|
+
* Gate order is a hard privacy invariant (SPEC §8.2 / §10):
|
|
11
|
+
* 1. resolved flags (host.workbuddy AND workbuddy_conversation_ingestion);
|
|
12
|
+
* 2. the REAL v3 consent record for hostKind='workbuddy';
|
|
13
|
+
* 3. only then any transcript filesystem read (pipeline's port).
|
|
14
|
+
* Steps 1 and 2 perform ZERO transcript port calls. Unlike the Codex path
|
|
15
|
+
* (which still hard-codes `consent: 'granted'` from its setup-flow invariant),
|
|
16
|
+
* this host reads the ledger at runtime, so revoking consent takes effect
|
|
17
|
+
* immediately.
|
|
18
|
+
*/
|
|
1
19
|
import { type HookHints, type TranscriptPort } from '@principles/host-runtime';
|
|
2
20
|
export interface WorkbuddyIngestionOptions {
|
|
3
21
|
/** Governance workspace (OD-07) — the v3 ledger and trajectory.db live here. */
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
* this host reads the ledger at runtime, so revoking consent takes effect
|
|
17
17
|
* immediately.
|
|
18
18
|
*/
|
|
19
|
-
import os from 'node:os';
|
|
20
19
|
import { readConversationIngestionConsent, runConversationIngestion, } from '@principles/host-runtime';
|
|
20
|
+
import { resolveWorkbuddyProjectsRoot, workbuddyProjectsRoot } from './transcript-path.js';
|
|
21
21
|
import { createWorkbuddyTranscriptSource } from './transcript-source.js';
|
|
22
22
|
/** Runtime-contract guard (rc-1): a non-null, non-array object is the only trusted payload shape. */
|
|
23
23
|
function isRecord(value) {
|
|
@@ -86,6 +86,24 @@ export function ingestWorkbuddyConversation(options) {
|
|
|
86
86
|
nextAction: 'Record a granted WorkBuddy ingestion decision with `pd workbuddy setup --accept` before any transcript is read.',
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
+
// 2b. Host transcript-root authority gate — BEFORE any transcript port
|
|
90
|
+
// call. The default follows the shared PD Home authority
|
|
91
|
+
// (WORKBUDDY_CONFIG_DIR override, PD_EXPERIMENT_ROOT isolation) so an
|
|
92
|
+
// experiment never reads the production WorkBuddy transcript tree; a
|
|
93
|
+
// refused resolution degrades observably instead of silently falling back
|
|
94
|
+
// to the OS home. An explicit options.home keeps the raw-home contract of
|
|
95
|
+
// the seam port (locate derives `<home>/.workbuddy/projects`).
|
|
96
|
+
const projectsRootResolution = options.home !== undefined
|
|
97
|
+
? { ok: true, root: workbuddyProjectsRoot(options.home) }
|
|
98
|
+
: resolveWorkbuddyProjectsRoot();
|
|
99
|
+
if (!projectsRootResolution.ok) {
|
|
100
|
+
return {
|
|
101
|
+
status: 'degraded',
|
|
102
|
+
reason: projectsRootResolution.reason,
|
|
103
|
+
nextAction: projectsRootResolution.nextAction,
|
|
104
|
+
warnings: [],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
89
107
|
// 3. Never ingest from a recursively-triggered Stop hook.
|
|
90
108
|
if (isRecord(options.rawPayload) && own(options.rawPayload, 'stop_hook_active') === true) {
|
|
91
109
|
return {
|
|
@@ -105,7 +123,7 @@ export function ingestWorkbuddyConversation(options) {
|
|
|
105
123
|
source: createWorkbuddyTranscriptSource({ now }),
|
|
106
124
|
session,
|
|
107
125
|
hints: workbuddyIngestionHints(options.rawPayload),
|
|
108
|
-
env: { home: options.home
|
|
126
|
+
env: options.home !== undefined ? { home: options.home } : {},
|
|
109
127
|
// The pipeline re-checks both gates; passing the real decision keeps a
|
|
110
128
|
// single source of truth and makes the port-spy invariant observable.
|
|
111
129
|
flags: { ingestionEnabled: true },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PdHomePaths } from '@principles/install-layout';
|
|
1
2
|
/** File identity captured at validation; the seam port re-proves it post-open. */
|
|
2
3
|
export interface WorkbuddyTranscriptFileIdentity {
|
|
3
4
|
readonly dev: number;
|
|
@@ -17,6 +18,14 @@ export type WorkbuddyTranscriptPathValidation = {
|
|
|
17
18
|
};
|
|
18
19
|
/** Projects root: `<home>/.workbuddy/projects` (engine-side join, forensics §2.2). */
|
|
19
20
|
export declare function workbuddyProjectsRoot(home: string): string;
|
|
21
|
+
export declare function resolveWorkbuddyProjectsRoot(homePaths?: PdHomePaths): {
|
|
22
|
+
ok: true;
|
|
23
|
+
root: string;
|
|
24
|
+
} | {
|
|
25
|
+
ok: false;
|
|
26
|
+
reason: string;
|
|
27
|
+
nextAction: string;
|
|
28
|
+
};
|
|
20
29
|
/**
|
|
21
30
|
* Authorize one transcript path against the WorkBuddy projects root.
|
|
22
31
|
*
|
|
@@ -28,12 +37,12 @@ export declare function workbuddyProjectsRoot(home: string): string;
|
|
|
28
37
|
export declare function validateWorkbuddyTranscriptPath(transcriptPath: string, projectsRoot: string): WorkbuddyTranscriptPathValidation;
|
|
29
38
|
/**
|
|
30
39
|
* Deterministic derivation (fallback when no hook payload path exists):
|
|
31
|
-
* `<
|
|
32
|
-
*
|
|
33
|
-
*
|
|
40
|
+
* `<projectsRoot>/<encodeCwd(cwd)>/<sessionId>.jsonl`. Returns null when the
|
|
41
|
+
* session identity or cwd cannot produce a contract-shaped path — the caller
|
|
42
|
+
* degrades, it never scans for a "latest" file.
|
|
34
43
|
*/
|
|
35
44
|
export declare function deriveWorkbuddyTranscriptPath(input: {
|
|
36
|
-
|
|
45
|
+
projectsRoot: string;
|
|
37
46
|
cwd: string;
|
|
38
47
|
sessionId: string;
|
|
39
48
|
}): string | null;
|