@phyzess/pappra 0.1.0-beta.13 → 0.1.0-beta.18
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/README.md +134 -15
- package/assets/integrations/skills/pappra/SKILL.md +28 -7
- package/assets/integrations/skills/pappra/references/collaboration.md +633 -0
- package/assets/integrations/skills/pappra/references/environment.md +360 -0
- package/assets/integrations/skills/pappra/references/hosts.md +20 -0
- package/assets/integrations/skills/pappra/references/operations.md +36 -5
- package/dist/adapters/pi/recovery-extension.d.ts +65 -0
- package/dist/adapters/pi/recovery-extension.js +238 -0
- package/dist/adapters/pi/session-transition-extension.d.ts +30 -0
- package/dist/adapters/pi/session-transition-extension.js +265 -0
- package/dist/app/automatic-handoff-events.d.ts +26 -0
- package/dist/app/automatic-handoff-events.js +134 -0
- package/dist/app/bounded-file.d.ts +2 -0
- package/dist/app/bounded-file.js +2 -0
- package/dist/app/capability-evidence/claude.d.ts +37 -0
- package/dist/app/capability-evidence/claude.js +206 -0
- package/dist/app/capability-evidence/codex.d.ts +35 -0
- package/dist/app/capability-evidence/codex.js +193 -0
- package/dist/app/capability-evidence/index.d.ts +33 -0
- package/dist/app/capability-evidence/index.js +117 -0
- package/dist/app/capability-evidence/pi.d.ts +73 -0
- package/dist/app/capability-evidence/pi.js +669 -0
- package/dist/app/capability-evidence/shared.d.ts +69 -0
- package/dist/app/capability-evidence/shared.js +195 -0
- package/dist/app/collab-auto-handoff.d.ts +55 -0
- package/dist/app/collab-auto-handoff.js +384 -0
- package/dist/app/collab-bindings.d.ts +57 -0
- package/dist/app/collab-bindings.js +1006 -0
- package/dist/app/collab-bootstrap-transport.d.ts +163 -0
- package/dist/app/collab-bootstrap-transport.js +769 -0
- package/dist/app/collab-bootstrap.d.ts +137 -0
- package/dist/app/collab-bootstrap.js +3455 -0
- package/dist/app/collab-handoff.d.ts +12 -0
- package/dist/app/collab-handoff.js +511 -0
- package/dist/app/collab-messages.d.ts +2 -0
- package/dist/app/collab-messages.js +2 -0
- package/dist/app/collab-notify.d.ts +156 -0
- package/dist/app/collab-notify.js +1208 -0
- package/dist/app/collab-preflight.d.ts +34 -0
- package/dist/app/collab-preflight.js +96 -0
- package/dist/app/collab-recovery-executor.d.ts +161 -0
- package/dist/app/collab-recovery-executor.js +1153 -0
- package/dist/app/collab-recovery-projection.d.ts +103 -0
- package/dist/app/collab-recovery-projection.js +659 -0
- package/dist/app/collab-recovery.d.ts +25 -0
- package/dist/app/collab-recovery.js +429 -0
- package/dist/app/collab-resources.d.ts +16 -0
- package/dist/app/collab-resources.js +278 -0
- package/dist/app/collab-role-events.d.ts +22 -0
- package/dist/app/collab-role-events.js +329 -0
- package/dist/app/collab-role-orchestration.d.ts +53 -0
- package/dist/app/collab-role-orchestration.js +601 -0
- package/dist/app/collab-role-plan.d.ts +81 -0
- package/dist/app/collab-role-plan.js +504 -0
- package/dist/app/collab-role-repair.d.ts +109 -0
- package/dist/app/collab-role-repair.js +821 -0
- package/dist/app/collab-rollover.d.ts +263 -0
- package/dist/app/collab-rollover.js +1112 -0
- package/dist/app/collab-route.d.ts +64 -0
- package/dist/app/collab-route.js +240 -0
- package/dist/app/collab-session-transition.d.ts +221 -0
- package/dist/app/collab-session-transition.js +3334 -0
- package/dist/app/collab-state.d.ts +7 -0
- package/dist/app/collab-state.js +162 -0
- package/dist/app/collab-task-store.d.ts +22 -0
- package/dist/app/collab-task-store.js +204 -0
- package/dist/app/collab-work-execution.d.ts +127 -0
- package/dist/app/collab-work-execution.js +1027 -0
- package/dist/app/collab-work-plan.d.ts +87 -0
- package/dist/app/collab-work-plan.js +437 -0
- package/dist/app/collaboration.d.ts +8 -2
- package/dist/app/collaboration.js +101 -12
- package/dist/app/doctor.js +108 -5
- package/dist/app/host-mcp.js +34 -8
- package/dist/app/host-probe.js +4 -4
- package/dist/app/init.d.ts +58 -4
- package/dist/app/init.js +768 -155
- package/dist/app/managed-pi-bootstrap-admission.d.ts +14 -0
- package/dist/app/managed-pi-bootstrap-admission.js +104 -0
- package/dist/app/managed-pi-bootstrap-refresh.d.ts +10 -0
- package/dist/app/managed-pi-bootstrap-refresh.js +78 -0
- package/dist/app/managed-pi-delivery.d.ts +8 -0
- package/dist/app/managed-pi-delivery.js +110 -0
- package/dist/app/managed-pi-handoff-receiver.d.ts +15 -0
- package/dist/app/managed-pi-handoff-receiver.js +263 -0
- package/dist/app/managed-pi-handoff-reference.d.ts +3 -0
- package/dist/app/managed-pi-handoff-reference.js +60 -0
- package/dist/app/managed-pi-herdr.d.ts +21 -0
- package/dist/app/managed-pi-herdr.js +185 -0
- package/dist/app/managed-pi-initial-admission.d.ts +28 -0
- package/dist/app/managed-pi-initial-admission.js +416 -0
- package/dist/app/managed-pi-initial-launch.d.ts +5 -0
- package/dist/app/managed-pi-initial-launch.js +61 -0
- package/dist/app/managed-pi-native-observation.d.ts +36 -0
- package/dist/app/managed-pi-native-observation.js +191 -0
- package/dist/app/managed-pi-readiness.d.ts +29 -0
- package/dist/app/managed-pi-readiness.js +288 -0
- package/dist/app/managed-pi-repair-stop.d.ts +21 -0
- package/dist/app/managed-pi-repair-stop.js +371 -0
- package/dist/app/managed-pi-resume-admission.d.ts +32 -0
- package/dist/app/managed-pi-resume-admission.js +618 -0
- package/dist/app/managed-pi-retirement.d.ts +28 -0
- package/dist/app/managed-pi-retirement.js +112 -0
- package/dist/app/managed-pi-sdk-control.d.ts +7 -0
- package/dist/app/managed-pi-sdk-control.js +169 -0
- package/dist/app/managed-pi-sdk-runtime.d.ts +3 -0
- package/dist/app/managed-pi-sdk-runtime.js +483 -0
- package/dist/app/managed-pi-source-admission.d.ts +14 -0
- package/dist/app/managed-pi-source-admission.js +323 -0
- package/dist/app/managed-pi-transition-host.d.ts +36 -0
- package/dist/app/managed-pi-transition-host.js +292 -0
- package/dist/app/managed-pi.d.ts +54 -0
- package/dist/app/managed-pi.js +248 -0
- package/dist/app/shell-readiness.d.ts +66 -0
- package/dist/app/shell-readiness.js +368 -0
- package/dist/app/task-pin.d.ts +2 -23
- package/dist/app/task-pin.js +2 -113
- package/dist/cli/commands/collaboration-binding.d.ts +13 -0
- package/dist/cli/commands/collaboration-binding.js +118 -0
- package/dist/cli/commands/collaboration-bootstrap.d.ts +10 -0
- package/dist/cli/commands/collaboration-bootstrap.js +84 -0
- package/dist/cli/commands/collaboration-capabilities.d.ts +13 -0
- package/dist/cli/commands/collaboration-capabilities.js +127 -0
- package/dist/cli/commands/collaboration-handoff.d.ts +13 -0
- package/dist/cli/commands/collaboration-handoff.js +102 -0
- package/dist/cli/commands/collaboration-message.d.ts +17 -0
- package/dist/cli/commands/collaboration-message.js +177 -0
- package/dist/cli/commands/collaboration-plan.d.ts +8 -0
- package/dist/cli/commands/collaboration-plan.js +108 -0
- package/dist/cli/commands/collaboration-preflight.d.ts +10 -0
- package/dist/cli/commands/collaboration-preflight.js +167 -0
- package/dist/cli/commands/collaboration-recovery-run.d.ts +46 -0
- package/dist/cli/commands/collaboration-recovery-run.js +224 -0
- package/dist/cli/commands/collaboration-recovery.d.ts +11 -0
- package/dist/cli/commands/collaboration-recovery.js +104 -0
- package/dist/cli/commands/collaboration-resources.d.ts +11 -0
- package/dist/cli/commands/collaboration-resources.js +96 -0
- package/dist/cli/commands/collaboration-role-plan.d.ts +9 -0
- package/dist/cli/commands/collaboration-role-plan.js +69 -0
- package/dist/cli/commands/collaboration-role-run.d.ts +11 -0
- package/dist/cli/commands/collaboration-role-run.js +128 -0
- package/dist/cli/commands/collaboration-rollover.d.ts +10 -0
- package/dist/cli/commands/collaboration-rollover.js +103 -0
- package/dist/cli/commands/collaboration-state.d.ts +10 -0
- package/dist/cli/commands/collaboration-state.js +96 -0
- package/dist/cli/commands/collaboration-transition.d.ts +10 -0
- package/dist/cli/commands/collaboration-transition.js +75 -0
- package/dist/cli/commands/collaboration-work-run.d.ts +34 -0
- package/dist/cli/commands/collaboration-work-run.js +178 -0
- package/dist/cli/commands/collaboration.d.ts +4 -0
- package/dist/cli/commands/collaboration.js +39 -4
- package/dist/cli/commands/continuity.js +2 -6
- package/dist/cli/commands/docs.d.ts +2 -0
- package/dist/cli/commands/docs.js +89 -15
- package/dist/cli/commands/host.d.ts +7 -1
- package/dist/cli/commands/host.js +122 -7
- package/dist/cli/commands/init.d.ts +20 -3
- package/dist/cli/commands/init.js +897 -232
- package/dist/cli/commands/mcp.d.ts +1 -0
- package/dist/cli/commands/mcp.js +11 -5
- package/dist/cli/commands/repair.d.ts +12 -0
- package/dist/cli/commands/repair.js +41 -0
- package/dist/cli/commands/runtime.d.ts +1 -1
- package/dist/cli/commands/runtime.js +139 -38
- package/dist/cli/commands/session.d.ts +7 -0
- package/dist/cli/commands/session.js +82 -0
- package/dist/cli/commands/task.js +19 -5
- package/dist/cli/run.js +866 -24
- package/dist/code/identity.d.ts +7 -0
- package/dist/code/identity.js +7 -3
- package/dist/code/registration.js +7 -0
- package/dist/code/service.d.ts +9 -0
- package/dist/code/service.js +16 -3
- package/dist/code/text.js +19 -7
- package/dist/collab/admission.d.ts +91 -66
- package/dist/collab/admission.js +21 -6
- package/dist/collab/canonical.d.ts +1 -1
- package/dist/collab/canonical.js +44 -3
- package/dist/collab/envelope.d.ts +2 -2
- package/dist/collab/envelope.js +12 -12
- package/dist/collab/first-work.d.ts +3 -0
- package/dist/collab/first-work.js +15 -0
- package/dist/collab/handoff.d.ts +16 -0
- package/dist/collab/handoff.js +39 -5
- package/dist/collab/index.d.ts +97 -1
- package/dist/collab/index.js +9 -1
- package/dist/collab/messages.js +126 -3
- package/dist/collab/persisted-messages.d.ts +123 -0
- package/dist/collab/persisted-messages.js +496 -0
- package/dist/collab/preflight.d.ts +1 -1
- package/dist/collab/resources.d.ts +13 -3
- package/dist/collab/resources.js +37 -6
- package/dist/collab/rollover.d.ts +311 -0
- package/dist/collab/rollover.js +1024 -0
- package/dist/collab/store.d.ts +1 -0
- package/dist/collab/store.js +1 -4
- package/dist/collab/types.d.ts +2 -354
- package/dist/collab/validation.d.ts +2 -10
- package/dist/collab/validation.js +2 -303
- package/dist/collab/work-plan.d.ts +105 -0
- package/dist/collab/work-plan.js +843 -0
- package/dist/continuity/context.d.ts +11 -2
- package/dist/continuity/context.js +100 -13
- package/dist/continuity/handoff-bundle.d.ts +296 -0
- package/dist/continuity/handoff-bundle.js +477 -0
- package/dist/continuity/index.d.ts +2 -0
- package/dist/continuity/index.js +1 -0
- package/dist/continuity/paths.js +10 -2
- package/dist/continuity/service.js +91 -15
- package/dist/continuity/task-pin.d.ts +24 -0
- package/dist/continuity/task-pin.js +590 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +6 -0
- package/dist/experimental/index.d.ts +13 -0
- package/dist/experimental/index.js +25 -0
- package/dist/experimental/pi.d.ts +4 -0
- package/dist/experimental/pi.js +12 -0
- package/dist/hosts/claude/native.js +1 -1
- package/dist/hosts/codex/native.js +1 -1
- package/dist/hosts/codex/protocol.js +1 -1
- package/dist/hosts/integration/bootstrap-config.d.ts +58 -0
- package/dist/hosts/integration/bootstrap-config.js +254 -0
- package/dist/hosts/integration/bundle-export.d.ts +44 -0
- package/dist/hosts/integration/bundle-export.js +366 -3
- package/dist/hosts/integration/bundle.js +3 -0
- package/dist/hosts/integration/hook.js +36 -9
- package/dist/hosts/integration/pappra-bootstrap-extension.mjs +80 -0
- package/dist/hosts/integration/pappra-extension-runtime.mjs +59 -24631
- package/dist/hosts/integration/pappra-hook.mjs +61 -24749
- package/dist/hosts/integration/pappra-recovery-extension.mjs +259 -0
- package/dist/hosts/integration/pappra-session-transition-extension.mjs +276 -0
- package/dist/hosts/integration/pi-bootstrap-extension.d.ts +36 -0
- package/dist/hosts/integration/pi-bootstrap-extension.js +101 -0
- package/dist/hosts/integration/pi-bootstrap-guard.d.ts +125 -0
- package/dist/hosts/integration/pi-bootstrap-guard.js +438 -0
- package/dist/hosts/integration/pi-bootstrap-runtime.d.ts +63 -0
- package/dist/hosts/integration/pi-bootstrap-runtime.js +223 -0
- package/dist/hosts/integration/pi-native-events.d.ts +112 -0
- package/dist/hosts/integration/pi-native-events.js +348 -0
- package/dist/hosts/integration/pi-rollover-extension.d.ts +166 -0
- package/dist/hosts/integration/pi-rollover-extension.js +431 -0
- package/dist/hosts/integration/recovery-config.d.ts +48 -0
- package/dist/hosts/integration/recovery-config.js +117 -0
- package/dist/hosts/integration/service.d.ts +6 -1
- package/dist/hosts/integration/service.js +485 -35
- package/dist/hosts/integration/support.d.ts +7 -0
- package/dist/hosts/integration/support.js +9 -1
- package/dist/hosts/integration/templates.d.ts +3 -0
- package/dist/hosts/integration/templates.js +26 -3
- package/dist/hosts/pi/managed-host-identity.d.ts +2 -0
- package/dist/hosts/pi/managed-host-identity.js +40 -0
- package/dist/hosts/pi/managed-provider-diagnostics.d.ts +6 -0
- package/dist/hosts/pi/managed-provider-diagnostics.js +184 -0
- package/dist/hosts/pi/managed-sdk-session.d.ts +335 -0
- package/dist/hosts/pi/managed-sdk-session.js +1639 -0
- package/dist/hosts/pi/managed-session-extension.d.ts +20 -0
- package/dist/hosts/pi/managed-session-extension.js +84 -0
- package/dist/hosts/pi/managed-session.d.ts +177 -0
- package/dist/hosts/pi/managed-session.js +1557 -0
- package/dist/hosts/pi/protocol.js +1 -1
- package/dist/hosts/pi/query-result.js +1 -1
- package/dist/hosts/pi/resume-capability.d.ts +41 -0
- package/dist/hosts/pi/resume-capability.js +33 -0
- package/dist/hosts/pi/rpc.d.ts +182 -134
- package/dist/hosts/pi/rpc.js +230 -37
- package/dist/hosts/pilot.d.ts +97 -74
- package/dist/hosts/pilot.js +5 -1
- package/dist/hosts/version.d.ts +3 -0
- package/dist/hosts/version.js +18 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/infra/bounded-file.d.ts +19 -0
- package/dist/infra/bounded-file.js +66 -0
- package/dist/infra/fs.js +10 -2
- package/dist/infra/git.d.ts +29 -0
- package/dist/infra/git.js +45 -9
- package/dist/infra/json-property.d.ts +2 -0
- package/dist/infra/json-property.js +69 -0
- package/dist/infra/json.d.ts +4 -0
- package/dist/infra/json.js +24 -0
- package/dist/infra/owned-process-group.js +1 -1
- package/dist/infra/private-lock.d.ts +16 -0
- package/dist/infra/private-lock.js +148 -0
- package/dist/infra/private-state.d.ts +7 -0
- package/dist/infra/private-state.js +146 -0
- package/dist/infra/process-identity.d.ts +12 -0
- package/dist/infra/process-identity.js +142 -0
- package/dist/infra/validation.d.ts +5 -0
- package/dist/infra/validation.js +15 -0
- package/dist/init.d.ts +1 -0
- package/dist/init.js +6 -0
- package/dist/install/apply.d.ts +9 -1
- package/dist/install/apply.js +176 -12
- package/dist/install/dependencies.d.ts +38 -0
- package/dist/install/dependencies.js +282 -0
- package/dist/install/ownership.js +30 -1
- package/dist/install/references.d.ts +31 -0
- package/dist/install/references.js +208 -0
- package/dist/install/repair.d.ts +37 -0
- package/dist/install/repair.js +798 -0
- package/dist/install/reset-local.d.ts +16 -0
- package/dist/install/reset-local.js +304 -0
- package/dist/install/rollback.d.ts +3 -0
- package/dist/install/rollback.js +9 -3
- package/dist/install/runtime.d.ts +10 -6
- package/dist/install/runtime.js +299 -59
- package/dist/install/source-fingerprint.d.ts +2 -0
- package/dist/install/source-fingerprint.js +103 -0
- package/dist/knowledge/catalog.d.ts +1 -0
- package/dist/knowledge/catalog.js +143 -10
- package/dist/knowledge/journal.js +17 -7
- package/dist/knowledge/paths.js +2 -1
- package/dist/knowledge/refs.js +4 -0
- package/dist/knowledge/register-batch.d.ts +4 -0
- package/dist/knowledge/register-batch.js +225 -0
- package/dist/knowledge/relocate.d.ts +5 -0
- package/dist/knowledge/relocate.js +92 -0
- package/dist/knowledge/scan.js +103 -47
- package/dist/knowledge/service.d.ts +3 -0
- package/dist/knowledge/service.js +33 -1
- package/dist/knowledge/write.d.ts +4 -1
- package/dist/knowledge/write.js +1 -1
- package/dist/mcp/server.d.ts +4 -2
- package/dist/mcp/server.js +87 -136
- package/dist/schemas/collaboration-state-validation.d.ts +6 -0
- package/dist/schemas/collaboration-state-validation.js +342 -0
- package/dist/schemas/collaboration-state.d.ts +436 -0
- package/dist/schemas/collaboration-state.js +1 -0
- package/dist/schemas/collaboration.d.ts +335 -0
- package/dist/schemas/collaboration.js +272 -0
- package/dist/schemas/continuity.d.ts +8 -0
- package/dist/schemas/continuity.js +13 -3
- package/dist/schemas/doctor.d.ts +1 -0
- package/dist/schemas/doctor.js +1 -0
- package/dist/schemas/document.d.ts +61 -0
- package/dist/schemas/document.js +9 -0
- package/dist/schemas/errors.d.ts +1 -0
- package/dist/schemas/errors.js +1 -0
- package/dist/schemas/host.d.ts +24 -0
- package/dist/schemas/host.js +19 -0
- package/dist/schemas/install.d.ts +8 -2
- package/dist/schemas/install.js +11 -1
- package/dist/schemas/managed-pi-execution.d.ts +16 -0
- package/dist/schemas/managed-pi-execution.js +2 -0
- package/dist/schemas/outcome.d.ts +9 -5
- package/dist/workspace/config-file.js +1 -3
- package/dist/workspace/documents.js +12 -2
- package/dist/workspace/repositories.d.ts +7 -0
- package/dist/workspace/repositories.js +14 -5
- package/package.json +35 -35
- package/skills/pappra/SKILL.md +28 -7
- package/skills/pappra/references/collaboration.md +633 -0
- package/skills/pappra/references/environment.md +360 -0
- package/skills/pappra/references/hosts.md +20 -0
- package/skills/pappra/references/operations.md +36 -5
- package/dist/app/collab-from.d.ts +0 -35
- package/dist/app/collab-from.js +0 -84
package/dist/knowledge/scan.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { discoverDocuments } from '../workspace/documents.js';
|
|
2
|
+
import { createDiagnostic } from '../schemas/diagnostics.js';
|
|
3
|
+
import { diagnosticCodes } from '../schemas/errors.js';
|
|
4
|
+
import { loadKnowledgeContext } from './context.js';
|
|
5
|
+
import { loadKnowledgeCatalogs } from './catalog.js';
|
|
6
|
+
import { registerDocumentBatch } from './register-batch.js';
|
|
3
7
|
export function classifyScannedDocumentKind(path) {
|
|
4
8
|
const lower = path.toLowerCase();
|
|
5
9
|
if (lower.endsWith('agents.md') || lower.endsWith('claude.md'))
|
|
@@ -14,25 +18,69 @@ export function classifyScannedDocumentKind(path) {
|
|
|
14
18
|
return 'plan';
|
|
15
19
|
return 'architecture';
|
|
16
20
|
}
|
|
21
|
+
function scanResult(root, mode, candidates, registered, skipped, diagnostics, nextActions, ok = !diagnostics.some((entry) => entry.severity === 'error')) {
|
|
22
|
+
return {
|
|
23
|
+
ok,
|
|
24
|
+
schema: 'pappra/docs-scan/1',
|
|
25
|
+
mode,
|
|
26
|
+
workspaceRoot: root,
|
|
27
|
+
candidates,
|
|
28
|
+
registered,
|
|
29
|
+
skipped,
|
|
30
|
+
nextActions,
|
|
31
|
+
diagnostics,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
17
34
|
/**
|
|
18
35
|
* Registers documents discovered under the configured knowledge sources.
|
|
19
36
|
* Without apply this is read-only and reports the candidates.
|
|
20
37
|
*/
|
|
21
38
|
export async function scanDiscoveredDocuments(root, options) {
|
|
22
|
-
const
|
|
23
|
-
const config =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
const loaded = await loadKnowledgeContext(root);
|
|
40
|
+
const config = loaded.context?.config ?? null;
|
|
41
|
+
const diagnostics = [...loaded.diagnostics];
|
|
42
|
+
const discovery = loaded.context === null
|
|
43
|
+
? { documents: [], diagnostics: [], truncated: false }
|
|
44
|
+
: await discoverDocuments({
|
|
45
|
+
root: loaded.context.root,
|
|
46
|
+
config,
|
|
47
|
+
configPath: loaded.context.configPath,
|
|
48
|
+
repositories: loaded.context.repositories,
|
|
49
|
+
options: {
|
|
50
|
+
scanDepth: 64,
|
|
51
|
+
maxDocuments: 10_000,
|
|
52
|
+
maxDirectories: 10_000,
|
|
53
|
+
maxEntriesPerDirectory: 10_000,
|
|
54
|
+
gitTimeoutMs: 5000,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
diagnostics.push(...discovery.diagnostics);
|
|
58
|
+
if (discovery.truncated) {
|
|
59
|
+
diagnostics.push(createDiagnostic({
|
|
60
|
+
code: diagnosticCodes.discoveryLimitReached,
|
|
61
|
+
severity: 'warning',
|
|
62
|
+
message: 'Knowledge source discovery was truncated; scan coverage is incomplete.',
|
|
63
|
+
source: root,
|
|
64
|
+
pointer: null,
|
|
65
|
+
hint: 'Reduce the configured sources or their size, then rerun the scan for complete coverage.',
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
if (config === null || loaded.context === null) {
|
|
69
|
+
return scanResult(root, options.apply ? 'apply' : 'plan', [], [], 0, diagnostics, [
|
|
70
|
+
'Run pappra init or repair .pappra/workspace.json before scanning knowledge sources.',
|
|
71
|
+
], false);
|
|
29
72
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
73
|
+
const listed = await loadKnowledgeCatalogs(loaded.context);
|
|
74
|
+
diagnostics.push(...listed.diagnostics);
|
|
75
|
+
if (!listed.ok) {
|
|
76
|
+
return scanResult(root, options.apply ? 'apply' : 'plan', [], [], 0, diagnostics, [
|
|
77
|
+
'Repair the knowledge catalog diagnostics before scanning; no registration was attempted.',
|
|
78
|
+
], false);
|
|
79
|
+
}
|
|
80
|
+
const registered = new Set([...listed.records.values()].flatMap((record) => record.location.kind === 'workspace' ? [record.location.path] : []));
|
|
33
81
|
const sources = config.knowledge.sources;
|
|
34
82
|
const visibility = config.knowledge.taskVisibility === 'shared' ? 'shareable' : 'private';
|
|
35
|
-
const
|
|
83
|
+
const discoveredCandidates = [];
|
|
36
84
|
for (const document of discovery.documents ?? []) {
|
|
37
85
|
const path = document.workspaceRelativePath;
|
|
38
86
|
if (path === null)
|
|
@@ -42,50 +90,58 @@ export async function scanDiscoveredDocuments(root, options) {
|
|
|
42
90
|
}
|
|
43
91
|
if (registered.has(path))
|
|
44
92
|
continue;
|
|
45
|
-
|
|
93
|
+
discoveredCandidates.push({
|
|
46
94
|
path,
|
|
47
95
|
kind: classifyScannedDocumentKind(path),
|
|
48
96
|
visibility,
|
|
49
97
|
});
|
|
50
98
|
}
|
|
51
|
-
const
|
|
99
|
+
const candidates = discoveredCandidates.slice(0, 300);
|
|
100
|
+
if (discoveredCandidates.length > candidates.length)
|
|
101
|
+
diagnostics.push(createDiagnostic({
|
|
102
|
+
code: diagnosticCodes.discoveryLimitReached,
|
|
103
|
+
severity: 'warning',
|
|
104
|
+
message: 'This batch contains 300 new documents; rerun scan after applying to continue with the remaining documents.',
|
|
105
|
+
source: root,
|
|
106
|
+
}));
|
|
107
|
+
const incomplete = discovery.truncated ||
|
|
108
|
+
discoveredCandidates.length > candidates.length ||
|
|
109
|
+
diagnostics.some((entry) => entry.severity === 'error');
|
|
110
|
+
const privateCommand = visibility === 'private' ? 'pappra docs list --include-private' : null;
|
|
52
111
|
if (!options.apply) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
nextActions:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
diagnostics,
|
|
65
|
-
};
|
|
112
|
+
const nextActions = [];
|
|
113
|
+
if (candidates.length > 0) {
|
|
114
|
+
nextActions.push('Rerun with --apply to register these documents in the knowledge catalog.');
|
|
115
|
+
}
|
|
116
|
+
if (incomplete || discovery.truncated) {
|
|
117
|
+
nextActions.push('Correct the reported knowledge-source diagnostics, then rerun the scan for complete coverage.');
|
|
118
|
+
}
|
|
119
|
+
if (privateCommand !== null) {
|
|
120
|
+
nextActions.push(`After applying, review private documents with: ${privateCommand}.`);
|
|
121
|
+
}
|
|
122
|
+
return scanResult(root, 'plan', candidates, [], candidates.length, diagnostics, nextActions, !incomplete);
|
|
66
123
|
}
|
|
67
124
|
const registeredNow = [];
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
125
|
+
const results = await registerDocumentBatch(loaded.context, candidates.map((candidate) => ({
|
|
126
|
+
location: { kind: 'workspace', path: candidate.path },
|
|
127
|
+
kind: candidate.kind,
|
|
128
|
+
maturity: 'draft',
|
|
129
|
+
owner: 'human',
|
|
130
|
+
visibility: candidate.visibility,
|
|
131
|
+
})));
|
|
132
|
+
for (const result of results) {
|
|
76
133
|
diagnostics.push(...result.diagnostics);
|
|
77
134
|
if (result.ok)
|
|
78
135
|
registeredNow.push(result.record);
|
|
79
136
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
137
|
+
const nextActions = [];
|
|
138
|
+
if (incomplete ||
|
|
139
|
+
discovery.truncated ||
|
|
140
|
+
registeredNow.length < candidates.length) {
|
|
141
|
+
nextActions.push('Coverage was incomplete or some registrations failed; correct the diagnostics and rerun the scan.');
|
|
142
|
+
}
|
|
143
|
+
if (privateCommand !== null) {
|
|
144
|
+
nextActions.push(`Review registered private documents with: ${privateCommand}.`);
|
|
145
|
+
}
|
|
146
|
+
return scanResult(root, 'apply', candidates, registeredNow, candidates.length - registeredNow.length, diagnostics, nextActions, !incomplete && !diagnostics.some((entry) => entry.severity === 'error'));
|
|
91
147
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DocumentLocation } from '../schemas/document.js';
|
|
1
2
|
import { type FreshnessReport } from './refs.js';
|
|
2
3
|
import type { ApplyWriteInput, ApplyWriteResult, ArchiveDocumentResult, DeleteExplicitInput, DeleteExplicitResult, DocumentCheckResult, ListDocumentsOptions, ListDocumentsResult, PreviewDeleteInput, PreviewDeleteResult, ProposeWriteInput, ProposeWriteResult, ReadDocumentResult, RegisterDocumentInput, RegisterDocumentResult, ShareDocumentResult, SupersedeDocumentInput, SupersedeDocumentResult, KnowledgeServiceOptions } from './types.js';
|
|
3
4
|
export declare class KnowledgeService {
|
|
@@ -5,6 +6,8 @@ export declare class KnowledgeService {
|
|
|
5
6
|
readonly root: string;
|
|
6
7
|
constructor(root: string, options?: KnowledgeServiceOptions);
|
|
7
8
|
register(input: RegisterDocumentInput): Promise<RegisterDocumentResult>;
|
|
9
|
+
relocate(documentId: string, location: DocumentLocation): Promise<RegisterDocumentResult>;
|
|
10
|
+
forget(documentId: string, scope?: 'shared' | 'private'): Promise<RegisterDocumentResult>;
|
|
8
11
|
read(documentId: string): Promise<ReadDocumentResult>;
|
|
9
12
|
list(options?: ListDocumentsOptions): Promise<ListDocumentsResult>;
|
|
10
13
|
check(options?: {
|
|
@@ -5,6 +5,7 @@ import { loadKnowledgeCatalogs } from './catalog.js';
|
|
|
5
5
|
import { inspectFreshness, findRecord } from './refs.js';
|
|
6
6
|
import { resolveKnowledgeLocation, readKnowledgeFile } from './paths.js';
|
|
7
7
|
import { applyWrite, proposeWrite, registerDocument } from './write.js';
|
|
8
|
+
import { relocateOrForgetDocument } from './relocate.js';
|
|
8
9
|
import { archiveDocument, deleteExplicit, previewDelete, shareDocument, supersedeDocument, } from './lifecycle.js';
|
|
9
10
|
const MAX_DOCUMENT_BYTES = 8 * 1024 * 1024;
|
|
10
11
|
function outcomeDiagnostic(failure, source) {
|
|
@@ -77,8 +78,17 @@ function filteredDiagnostics(context, catalogs, includePrivate) {
|
|
|
77
78
|
if (includePrivate)
|
|
78
79
|
return diagnostics;
|
|
79
80
|
const privatePrefix = `${context.root}/.pappra/local/knowledge`;
|
|
80
|
-
|
|
81
|
+
const visible = diagnostics.filter((entry) => entry.source !== privatePrefix &&
|
|
81
82
|
!entry.source.startsWith(`${privatePrefix}/`));
|
|
83
|
+
if (!catalogs.ok && !visible.some((entry) => entry.severity === 'error'))
|
|
84
|
+
visible.push(createDiagnostic({
|
|
85
|
+
code: diagnosticCodes.document_catalog_conflict,
|
|
86
|
+
severity: 'error',
|
|
87
|
+
message: 'A private knowledge catalog conflict blocks this operation.',
|
|
88
|
+
source: context.configPath,
|
|
89
|
+
hint: 'Run pappra docs list --include-private to inspect the conflict; use docs forget to remove an obsolete registration without deleting its file.',
|
|
90
|
+
}));
|
|
91
|
+
return visible;
|
|
82
92
|
}
|
|
83
93
|
export class KnowledgeService {
|
|
84
94
|
root;
|
|
@@ -99,6 +109,28 @@ export class KnowledgeService {
|
|
|
99
109
|
}
|
|
100
110
|
return registerDocument(loaded.context, input);
|
|
101
111
|
}
|
|
112
|
+
async relocate(documentId, location) {
|
|
113
|
+
const loaded = await getContext(this.root);
|
|
114
|
+
if (!loaded.ok)
|
|
115
|
+
return {
|
|
116
|
+
ok: false,
|
|
117
|
+
status: 'failed',
|
|
118
|
+
record: null,
|
|
119
|
+
diagnostics: loaded.diagnostics,
|
|
120
|
+
};
|
|
121
|
+
return relocateOrForgetDocument(loaded.context, documentId, location);
|
|
122
|
+
}
|
|
123
|
+
async forget(documentId, scope) {
|
|
124
|
+
const loaded = await getContext(this.root);
|
|
125
|
+
if (!loaded.ok)
|
|
126
|
+
return {
|
|
127
|
+
ok: false,
|
|
128
|
+
status: 'failed',
|
|
129
|
+
record: null,
|
|
130
|
+
diagnostics: loaded.diagnostics,
|
|
131
|
+
};
|
|
132
|
+
return relocateOrForgetDocument(loaded.context, documentId, null, scope);
|
|
133
|
+
}
|
|
102
134
|
async read(documentId) {
|
|
103
135
|
const loaded = await getContext(this.root);
|
|
104
136
|
if (!loaded.ok) {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { type DocumentWriteProposal } from '../schemas/document.js';
|
|
1
|
+
import { type DocumentRecord, type DocumentWriteProposal } from '../schemas/document.js';
|
|
2
|
+
import { type Outcome } from '../schemas/outcome.js';
|
|
2
3
|
import type { KnowledgeContext } from './context.js';
|
|
4
|
+
import { type ResolvedKnowledgeLocation } from './paths.js';
|
|
3
5
|
import type { ApplyWriteInput, ApplyWriteResult, KnowledgeServiceOptions, ProposeWriteInput, ProposeWriteResult, RegisterDocumentInput, RegisterDocumentResult } from './types.js';
|
|
4
6
|
export declare function defaultVisibility(context: KnowledgeContext): 'private' | 'shareable';
|
|
7
|
+
export declare function validateAndBuildRecord(context: KnowledgeContext, input: RegisterDocumentInput, location: ResolvedKnowledgeLocation): Promise<Outcome<DocumentRecord>>;
|
|
5
8
|
export declare function registerDocument(context: KnowledgeContext, input: RegisterDocumentInput): Promise<RegisterDocumentResult>;
|
|
6
9
|
export declare function proposeWrite(context: KnowledgeContext, input: ProposeWriteInput): Promise<ProposeWriteResult>;
|
|
7
10
|
export declare function applyWrite(input: ApplyWriteInput, root: string, options?: KnowledgeServiceOptions): Promise<ApplyWriteResult>;
|
package/dist/knowledge/write.js
CHANGED
|
@@ -99,7 +99,7 @@ function recordDiagnostics(record, source) {
|
|
|
99
99
|
diagnostic(diagnosticCodes.document_record_invalid, `Document record is invalid: ${parsed.error.issues[0]?.message ?? 'unknown issue'}`, source, 'Fix the record metadata; no catalog bytes were written.'),
|
|
100
100
|
];
|
|
101
101
|
}
|
|
102
|
-
async function validateAndBuildRecord(context, input, location) {
|
|
102
|
+
export async function validateAndBuildRecord(context, input, location) {
|
|
103
103
|
const documentId = input.documentId ?? randomUUID();
|
|
104
104
|
const visibility = input.visibility ?? defaultVisibility(context);
|
|
105
105
|
const sources = input.sources ?? [];
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
export declare const MCP_SERVER_NAME = "pappra";
|
|
3
3
|
export interface PappraMcpServerOptions {
|
|
4
4
|
readonly root: string;
|
|
5
|
+
/** Trusted server-launch policy, never accepted from tool arguments. */
|
|
6
|
+
readonly allowWorkspaceWrites?: boolean;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* Builds the stdio MCP server for one workspace. Tools are read-only here; write
|
|
8
|
-
* operations
|
|
10
|
+
* operations require a trusted launch policy; tool flags only select preview/apply.
|
|
9
11
|
*/
|
|
10
12
|
export declare function createPappraMcpServer(options: PappraMcpServerOptions): McpServer;
|
|
11
|
-
export declare function runMcpServer(root: string): Promise<void>;
|
|
13
|
+
export declare function runMcpServer(root: string, allowWorkspaceWrites?: boolean): Promise<void>;
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import path from 'node:path';
|
|
4
5
|
import { discoverWorkspace } from '../workspace/discover.js';
|
|
5
6
|
import { inspectMachineConfig, inspectWorkspaceConfig, } from '../workspace/config.js';
|
|
6
7
|
import { inspectRuntimeStatePassive } from '../install/runtime.js';
|
|
@@ -10,11 +11,18 @@ import { CodeIntelligenceService } from '../code/index.js';
|
|
|
10
11
|
import { HOST_SUPPORT } from '../hosts/integration/support.js';
|
|
11
12
|
import { getPackageInfo } from '../package-info.js';
|
|
12
13
|
import { scanDiscoveredDocuments } from '../knowledge/scan.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { prepareCollaboration } from '../app/collaboration.js';
|
|
15
|
+
import { collaborationGoalSchema } from '../schemas/collaboration.js';
|
|
16
|
+
import { canonicalizeTarget } from '../collab/canonical.js';
|
|
17
|
+
import { isPathInside } from '../schemas/paths.js';
|
|
17
18
|
export const MCP_SERVER_NAME = 'pappra';
|
|
19
|
+
function cliRequired(command) {
|
|
20
|
+
return {
|
|
21
|
+
ok: false,
|
|
22
|
+
status: 'cli_required',
|
|
23
|
+
message: `${command} requires an authorized CLI invocation. A tool-supplied apply flag is not user approval.`,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
18
26
|
function toolResult(value, isError = false) {
|
|
19
27
|
return {
|
|
20
28
|
content: [
|
|
@@ -39,10 +47,11 @@ async function errorResult(action) {
|
|
|
39
47
|
}
|
|
40
48
|
/**
|
|
41
49
|
* Builds the stdio MCP server for one workspace. Tools are read-only here; write
|
|
42
|
-
* operations
|
|
50
|
+
* operations require a trusted launch policy; tool flags only select preview/apply.
|
|
43
51
|
*/
|
|
44
52
|
export function createPappraMcpServer(options) {
|
|
45
53
|
const root = options.root;
|
|
54
|
+
const allowWorkspaceWrites = options.allowWorkspaceWrites === true;
|
|
46
55
|
const server = new McpServer({
|
|
47
56
|
name: MCP_SERVER_NAME,
|
|
48
57
|
version: getPackageInfo().version,
|
|
@@ -222,13 +231,15 @@ export function createPappraMcpServer(options) {
|
|
|
222
231
|
provider: result.result?.provider ?? null,
|
|
223
232
|
coverage: result.result?.coverage ?? null,
|
|
224
233
|
items: result.result?.items ?? [],
|
|
234
|
+
truncated: result.result?.truncated ?? false,
|
|
235
|
+
reasons: result.result?.reasons ?? [],
|
|
225
236
|
health: result.health,
|
|
226
237
|
diagnostics: result.diagnostics,
|
|
227
238
|
};
|
|
228
239
|
}));
|
|
229
240
|
server.registerTool('checkpoint', {
|
|
230
241
|
title: 'Write a task checkpoint',
|
|
231
|
-
description: 'Writes an advisory checkpoint
|
|
242
|
+
description: 'Writes an advisory checkpoint only when trusted server startup enables workspace writes. apply selects persistence and never grants authorization.',
|
|
232
243
|
inputSchema: {
|
|
233
244
|
task: z.string().min(1).max(256),
|
|
234
245
|
objective: z.string().min(1).max(4000),
|
|
@@ -245,13 +256,15 @@ export function createPappraMcpServer(options) {
|
|
|
245
256
|
nativeSession: z.string().min(1).max(256).optional(),
|
|
246
257
|
apply: z.boolean(),
|
|
247
258
|
},
|
|
248
|
-
annotations: { readOnlyHint:
|
|
259
|
+
annotations: { readOnlyHint: !allowWorkspaceWrites },
|
|
249
260
|
}, async (args) => errorResult(async () => {
|
|
261
|
+
if (!allowWorkspaceWrites)
|
|
262
|
+
return cliRequired('pappra checkpoint');
|
|
250
263
|
if (args.apply !== true) {
|
|
251
264
|
return {
|
|
252
265
|
ok: false,
|
|
253
|
-
status: '
|
|
254
|
-
message: '
|
|
266
|
+
status: 'preview',
|
|
267
|
+
message: 'Preview only. The trusted host has enabled workspace writes; apply selects persistence, not authorization.',
|
|
255
268
|
};
|
|
256
269
|
}
|
|
257
270
|
const nativeRefs = args.nativeSession === undefined
|
|
@@ -308,10 +321,12 @@ export function createPappraMcpServer(options) {
|
|
|
308
321
|
}));
|
|
309
322
|
server.registerTool('docs_scan', {
|
|
310
323
|
title: 'Scan knowledge sources',
|
|
311
|
-
description: '
|
|
324
|
+
description: 'Previews discovered knowledge documents. Applying requires trusted server startup workspace-write policy; tool flags do not grant it.',
|
|
312
325
|
inputSchema: { apply: z.boolean().optional() },
|
|
313
|
-
annotations: { readOnlyHint:
|
|
326
|
+
annotations: { readOnlyHint: !allowWorkspaceWrites },
|
|
314
327
|
}, async (args) => errorResult(async () => {
|
|
328
|
+
if (args.apply === true && !allowWorkspaceWrites)
|
|
329
|
+
return cliRequired('pappra docs scan --apply');
|
|
315
330
|
const result = await scanDiscoveredDocuments(root, {
|
|
316
331
|
apply: args.apply === true,
|
|
317
332
|
});
|
|
@@ -319,19 +334,21 @@ export function createPappraMcpServer(options) {
|
|
|
319
334
|
}));
|
|
320
335
|
server.registerTool('code_prepare', {
|
|
321
336
|
title: 'Prepare a repository code index',
|
|
322
|
-
description: '
|
|
337
|
+
description: 'Previews repository index preparation. Engine execution requires an authorized CLI command.',
|
|
323
338
|
inputSchema: {
|
|
324
339
|
repo: z.string().min(1).max(128),
|
|
325
340
|
apply: z.boolean().optional(),
|
|
326
341
|
rebuild: z.boolean().optional(),
|
|
327
342
|
},
|
|
328
|
-
annotations: { readOnlyHint:
|
|
343
|
+
annotations: { readOnlyHint: true },
|
|
329
344
|
}, async (args) => errorResult(async () => {
|
|
345
|
+
if (args.apply === true)
|
|
346
|
+
return cliRequired('pappra code prepare --apply');
|
|
330
347
|
const service = new CodeIntelligenceService(root);
|
|
331
348
|
const result = await service.prepare({
|
|
332
349
|
root,
|
|
333
350
|
repositoryId: args.repo,
|
|
334
|
-
apply:
|
|
351
|
+
apply: false,
|
|
335
352
|
rebuild: args.rebuild === true,
|
|
336
353
|
});
|
|
337
354
|
return {
|
|
@@ -345,147 +362,81 @@ export function createPappraMcpServer(options) {
|
|
|
345
362
|
}));
|
|
346
363
|
server.registerTool('runtime_install', {
|
|
347
364
|
title: 'Install the durable runtime',
|
|
348
|
-
description: '
|
|
349
|
-
inputSchema: {
|
|
350
|
-
from: z.
|
|
351
|
-
version: z.string().min(1).max(128).optional(),
|
|
352
|
-
tarball: z.string().min(1).max(4096).optional(),
|
|
365
|
+
description: 'Reports CLI guidance for runtime installation; MCP never installs or executes package code. Only from:self is accepted.',
|
|
366
|
+
inputSchema: z.strictObject({
|
|
367
|
+
from: z.literal('self').optional(),
|
|
353
368
|
apply: z.boolean(),
|
|
354
|
-
},
|
|
355
|
-
annotations: { readOnlyHint:
|
|
369
|
+
}),
|
|
370
|
+
annotations: { readOnlyHint: true },
|
|
356
371
|
}, async (args) => errorResult(async () => {
|
|
357
372
|
const from = args.from ?? 'self';
|
|
358
|
-
const version =
|
|
359
|
-
if (args.apply !== true) {
|
|
360
|
-
return {
|
|
361
|
-
ok: false,
|
|
362
|
-
status: 'confirmation_required',
|
|
363
|
-
message: 'runtime_install writes a durable copy and machine.json; call again with apply: true.',
|
|
364
|
-
version,
|
|
365
|
-
from,
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
if (from === 'self') {
|
|
369
|
-
const result = await ensureDefaultRuntime(root, version);
|
|
370
|
-
return {
|
|
371
|
-
ok: result.ok && result.completion,
|
|
372
|
-
completion: result.completion,
|
|
373
|
-
runtime: result.runtime,
|
|
374
|
-
diagnostics: result.diagnostics,
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
const tarball = args.tarball;
|
|
378
|
-
if (from === 'tarball' && tarball === undefined) {
|
|
379
|
-
return {
|
|
380
|
-
ok: false,
|
|
381
|
-
message: 'from: tarball requires the tarball path.',
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
const installed = await installRuntime({
|
|
385
|
-
version,
|
|
386
|
-
source: from === 'tarball' && tarball !== undefined
|
|
387
|
-
? { kind: 'tarball', path: tarball }
|
|
388
|
-
: { kind: 'version' },
|
|
389
|
-
packageName: getPackageInfo().name,
|
|
390
|
-
});
|
|
391
|
-
const bound = await bindAndRecordRuntime(root, installed);
|
|
373
|
+
const version = getPackageInfo().version;
|
|
392
374
|
return {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
diagnostics: bound.diagnostics,
|
|
375
|
+
...cliRequired('pappra runtime install --from self --apply'),
|
|
376
|
+
version,
|
|
377
|
+
from,
|
|
397
378
|
};
|
|
398
379
|
}));
|
|
399
380
|
server.registerTool('collab_prepare', {
|
|
400
381
|
title: 'Prepare a bounded collaboration',
|
|
401
|
-
description: '
|
|
402
|
-
inputSchema: {
|
|
382
|
+
description: 'Prepares a bounded collaboration from an explicit shared pappra/collaboration-goal/1 document plus a shared domain root, then claims its resources. Identities, configuration, cwd, roles and capabilities are never inferred. No capability card is generated: derive and preflight actual runtime evidence separately before a user-authorized CLI launch. The legacy flat objective form is unsupported.',
|
|
383
|
+
inputSchema: z.strictObject({
|
|
403
384
|
domainRoot: z.string().min(1).max(4096),
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
resources: z
|
|
408
|
-
.array(z.object({
|
|
409
|
-
path: z.string().min(1).max(4096),
|
|
410
|
-
access: z.enum(['read', 'write']),
|
|
411
|
-
}))
|
|
412
|
-
.min(1)
|
|
413
|
-
.max(32),
|
|
414
|
-
coordinatorSession: z.string().min(1).max(256),
|
|
415
|
-
assigneeSession: z.string().min(1).max(256),
|
|
416
|
-
harness: z.enum(['pi', 'codex', 'claude']).optional(),
|
|
417
|
-
subtaskId: z.string().min(1).max(128).optional(),
|
|
418
|
-
attempt: z.number().int().min(1).max(1000).optional(),
|
|
419
|
-
phase: z
|
|
420
|
-
.enum(['discovery', 'implementation', 'review', 'handoff', 'fix'])
|
|
421
|
-
.optional(),
|
|
422
|
-
prompt: z.string().min(1).max(20000).optional(),
|
|
423
|
-
},
|
|
424
|
-
annotations: { readOnlyHint: false },
|
|
385
|
+
goal: collaborationGoalSchema,
|
|
386
|
+
}),
|
|
387
|
+
annotations: { readOnlyHint: !allowWorkspaceWrites },
|
|
425
388
|
}, async (args) => errorResult(async () => {
|
|
426
|
-
|
|
389
|
+
if (!allowWorkspaceWrites)
|
|
390
|
+
return cliRequired('pappra collab prepare');
|
|
391
|
+
const workspace = canonicalizeTarget(path.resolve(root)).path;
|
|
392
|
+
const privateDomain = path.join(workspace, '.pappra', 'local', 'collaboration');
|
|
393
|
+
const domain = canonicalizeTarget(path.resolve(args.domainRoot)).path;
|
|
394
|
+
if (!isPathInside(privateDomain, domain) ||
|
|
395
|
+
!isPathInside(workspace, canonicalizeTarget(args.goal.assignee.cwd).path) ||
|
|
396
|
+
args.goal.resources.some((resource) => !isPathInside(workspace, canonicalizeTarget(resource.path).path)))
|
|
397
|
+
return {
|
|
398
|
+
ok: false,
|
|
399
|
+
status: 'scope_refused',
|
|
400
|
+
message: 'MCP preparation is limited to a private workspace collaboration domain and workspace-local resources; use the authorized CLI for other scopes.',
|
|
401
|
+
};
|
|
402
|
+
const result = await prepareCollaboration(args.goal, {
|
|
427
403
|
domainRoot: args.domainRoot,
|
|
428
|
-
objective: args.objective,
|
|
429
|
-
taskId: args.task,
|
|
430
|
-
acceptance: args.acceptance,
|
|
431
|
-
resources: args.resources,
|
|
432
|
-
coordinatorSession: args.coordinatorSession,
|
|
433
|
-
assigneeSession: args.assigneeSession,
|
|
434
|
-
...(args.harness === undefined ? {} : { harness: args.harness }),
|
|
435
|
-
...(args.subtaskId === undefined
|
|
436
|
-
? {}
|
|
437
|
-
: { subtaskId: args.subtaskId }),
|
|
438
|
-
...(args.attempt === undefined ? {} : { attempt: args.attempt }),
|
|
439
|
-
...(args.phase === undefined ? {} : { phase: args.phase }),
|
|
440
|
-
...(args.prompt === undefined ? {} : { prompt: args.prompt }),
|
|
441
404
|
});
|
|
442
|
-
|
|
405
|
+
if (!result.ok) {
|
|
406
|
+
return {
|
|
407
|
+
ok: false,
|
|
408
|
+
status: result.status,
|
|
409
|
+
code: result.code,
|
|
410
|
+
message: result.message,
|
|
411
|
+
nextAction: result.nextAction,
|
|
412
|
+
diagnostics: result.diagnostics,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
return {
|
|
416
|
+
ok: true,
|
|
417
|
+
prepared: result.value.prepared,
|
|
418
|
+
goal: result.value.goal,
|
|
419
|
+
notes: [
|
|
420
|
+
'No capability card is generated and no observation timestamp is manufactured. Supply actual capability evidence: derive a runtime card with pappra collab capabilities derive from the receiving session, check it with pappra collab preflight, then ask the user to launch with pappra collab run in the CLI.',
|
|
421
|
+
'The removed cardPath/card outputs were declared-only evidence and never authorized a launch.',
|
|
422
|
+
],
|
|
423
|
+
};
|
|
443
424
|
}));
|
|
444
425
|
server.registerTool('collab_start', {
|
|
445
426
|
title: 'Start one admitted collaboration launch',
|
|
446
|
-
description: '
|
|
427
|
+
description: 'Returns CLI guidance without launching. The user must launch through the CLI; an agent-supplied confirm flag is not user approval.',
|
|
447
428
|
inputSchema: {
|
|
448
429
|
prepared: z.string().min(1).max(4096),
|
|
449
430
|
capabilities: z.string().min(1).max(4096),
|
|
450
431
|
controller: z.enum(['fixture', 'pi-rpc']),
|
|
451
432
|
confirm: z.boolean(),
|
|
452
433
|
},
|
|
453
|
-
annotations: { readOnlyHint:
|
|
454
|
-
}, async (
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
message: 'collab_start launches a process; the user must confirm before calling it with confirm: true.',
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
const controller = args.controller === 'fixture'
|
|
463
|
-
? new FixtureController()
|
|
464
|
-
: new PiRpcController();
|
|
465
|
-
const started = await startPrepared(args.prepared, {
|
|
466
|
-
capabilitiesFile: args.capabilities,
|
|
467
|
-
controller,
|
|
468
|
-
controllerId: controller.id,
|
|
469
|
-
});
|
|
470
|
-
if (!started.ok)
|
|
471
|
-
return started;
|
|
472
|
-
try {
|
|
473
|
-
const finished = await finishStarted(started.value);
|
|
474
|
-
if (!finished.ok) {
|
|
475
|
-
return finished;
|
|
476
|
-
}
|
|
477
|
-
const report = submitResultReport(started.value, finished.value);
|
|
478
|
-
return {
|
|
479
|
-
ok: report.ok,
|
|
480
|
-
status: finished.value.status,
|
|
481
|
-
report,
|
|
482
|
-
finish: finished.value,
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
finally {
|
|
486
|
-
await started.value.session.dispose?.().catch(() => undefined);
|
|
487
|
-
}
|
|
488
|
-
}));
|
|
434
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
435
|
+
}, async () => errorResult(async () => ({
|
|
436
|
+
ok: false,
|
|
437
|
+
status: 'cli_required',
|
|
438
|
+
message: 'MCP cannot authorize process launches. Ask the user to run pappra collab run --prepared <file> --capabilities <file> --controller <controller> --confirm in the CLI.',
|
|
439
|
+
})));
|
|
489
440
|
server.registerTool('runtime_status', {
|
|
490
441
|
title: 'Runtime status',
|
|
491
442
|
description: 'Reports the workspace runtime binding and passive runtime state.',
|
|
@@ -511,8 +462,8 @@ export function createPappraMcpServer(options) {
|
|
|
511
462
|
}));
|
|
512
463
|
return server;
|
|
513
464
|
}
|
|
514
|
-
export async function runMcpServer(root) {
|
|
515
|
-
const server = createPappraMcpServer({ root });
|
|
465
|
+
export async function runMcpServer(root, allowWorkspaceWrites = false) {
|
|
466
|
+
const server = createPappraMcpServer({ root, allowWorkspaceWrites });
|
|
516
467
|
const transport = new StdioServerTransport();
|
|
517
468
|
await server.connect(transport);
|
|
518
469
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TaskRecord, LockHolder, Message, Notification } from './collaboration-state.js';
|
|
2
|
+
export { object, text, errorCode, parseJson } from '../infra/validation.js';
|
|
3
|
+
export declare function isTaskRecord(value: unknown): value is TaskRecord;
|
|
4
|
+
export declare function isLockHolder(value: unknown): value is LockHolder;
|
|
5
|
+
export declare function isMessage(value: unknown): value is Message;
|
|
6
|
+
export declare function isNotification(value: unknown): value is Notification;
|