@phyzess/pappra 0.0.0-stage → 0.1.0-beta.10
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/LICENSE +21 -0
- package/README.md +99 -2
- package/THIRD_PARTY_NOTICES.md +16 -0
- package/assets/integrations/skills/pappra/SKILL.md +71 -0
- package/assets/integrations/skills/pappra/references/hosts.md +40 -0
- package/assets/integrations/skills/pappra/references/lifecycle.md +41 -0
- package/assets/integrations/skills/pappra/references/operations.md +27 -0
- package/assets/manifest.json +4 -0
- package/dist/app/collaboration.d.ts +170 -0
- package/dist/app/collaboration.js +1643 -0
- package/dist/app/doctor.d.ts +9 -0
- package/dist/app/doctor.js +1030 -0
- package/dist/app/init.d.ts +171 -0
- package/dist/app/init.js +1442 -0
- package/dist/cli/commands/code.d.ts +16 -0
- package/dist/cli/commands/code.js +127 -0
- package/dist/cli/commands/collaboration.d.ts +13 -0
- package/dist/cli/commands/collaboration.js +186 -0
- package/dist/cli/commands/continuity.d.ts +29 -0
- package/dist/cli/commands/continuity.js +133 -0
- package/dist/cli/commands/docs.d.ts +12 -0
- package/dist/cli/commands/docs.js +234 -0
- package/dist/cli/commands/doctor.d.ts +14 -0
- package/dist/cli/commands/doctor.js +57 -0
- package/dist/cli/commands/host.d.ts +17 -0
- package/dist/cli/commands/host.js +199 -0
- package/dist/cli/commands/init.d.ts +59 -0
- package/dist/cli/commands/init.js +845 -0
- package/dist/cli/commands/runtime.d.ts +14 -0
- package/dist/cli/commands/runtime.js +263 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +10 -0
- package/dist/cli/output.d.ts +4 -0
- package/dist/cli/output.js +1 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.js +749 -0
- package/dist/code/budget.d.ts +14 -0
- package/dist/code/budget.js +39 -0
- package/dist/code/exec.d.ts +23 -0
- package/dist/code/exec.js +133 -0
- package/dist/code/identity.d.ts +13 -0
- package/dist/code/identity.js +214 -0
- package/dist/code/index.d.ts +6 -0
- package/dist/code/index.js +3 -0
- package/dist/code/providers/codegraph.d.ts +59 -0
- package/dist/code/providers/codegraph.js +567 -0
- package/dist/code/registration.d.ts +9 -0
- package/dist/code/registration.js +293 -0
- package/dist/code/service.d.ts +53 -0
- package/dist/code/service.js +633 -0
- package/dist/code/text.d.ts +3 -0
- package/dist/code/text.js +202 -0
- package/dist/collab/admission.d.ts +450 -0
- package/dist/collab/admission.js +797 -0
- package/dist/collab/canonical.d.ts +26 -0
- package/dist/collab/canonical.js +136 -0
- package/dist/collab/contracts.d.ts +73 -0
- package/dist/collab/contracts.js +76 -0
- package/dist/collab/envelope.d.ts +52 -0
- package/dist/collab/envelope.js +241 -0
- package/dist/collab/fingerprint.d.ts +7 -0
- package/dist/collab/fingerprint.js +58 -0
- package/dist/collab/handoff.d.ts +350 -0
- package/dist/collab/handoff.js +513 -0
- package/dist/collab/index.d.ts +9 -0
- package/dist/collab/index.js +8 -0
- package/dist/collab/lifecycle.d.ts +449 -0
- package/dist/collab/lifecycle.js +534 -0
- package/dist/collab/messages.d.ts +148 -0
- package/dist/collab/messages.js +583 -0
- package/dist/collab/notify.d.ts +47 -0
- package/dist/collab/notify.js +140 -0
- package/dist/collab/preflight.d.ts +31 -0
- package/dist/collab/preflight.js +271 -0
- package/dist/collab/resources.d.ts +119 -0
- package/dist/collab/resources.js +451 -0
- package/dist/collab/store.d.ts +143 -0
- package/dist/collab/store.js +606 -0
- package/dist/collab/types.d.ts +354 -0
- package/dist/collab/types.js +1 -0
- package/dist/collab/validation.d.ts +10 -0
- package/dist/collab/validation.js +303 -0
- package/dist/continuity/context.d.ts +24 -0
- package/dist/continuity/context.js +179 -0
- package/dist/continuity/index.d.ts +3 -0
- package/dist/continuity/index.js +1 -0
- package/dist/continuity/paths.d.ts +37 -0
- package/dist/continuity/paths.js +258 -0
- package/dist/continuity/service.d.ts +59 -0
- package/dist/continuity/service.js +1258 -0
- package/dist/hosts/claude/native.d.ts +79 -0
- package/dist/hosts/claude/native.js +853 -0
- package/dist/hosts/codex/native.d.ts +345 -0
- package/dist/hosts/codex/native.js +1528 -0
- package/dist/hosts/codex/protocol.d.ts +51 -0
- package/dist/hosts/codex/protocol.js +42 -0
- package/dist/hosts/detect.d.ts +29 -0
- package/dist/hosts/detect.js +73 -0
- package/dist/hosts/index.d.ts +10 -0
- package/dist/hosts/index.js +10 -0
- package/dist/hosts/integration/bundle-export.d.ts +24 -0
- package/dist/hosts/integration/bundle-export.js +128 -0
- package/dist/hosts/integration/bundle.d.ts +19 -0
- package/dist/hosts/integration/bundle.js +99 -0
- package/dist/hosts/integration/hook-entry.d.ts +1 -0
- package/dist/hosts/integration/hook-entry.js +68 -0
- package/dist/hosts/integration/hook.d.ts +32 -0
- package/dist/hosts/integration/hook.js +781 -0
- package/dist/hosts/integration/pappra-extension-runtime.mjs +24610 -0
- package/dist/hosts/integration/pappra-hook.mjs +24728 -0
- package/dist/hosts/integration/pi-extension-runtime.d.ts +18 -0
- package/dist/hosts/integration/pi-extension-runtime.js +89 -0
- package/dist/hosts/integration/pi-template.d.ts +3 -0
- package/dist/hosts/integration/pi-template.js +5 -0
- package/dist/hosts/integration/service.d.ts +49 -0
- package/dist/hosts/integration/service.js +1421 -0
- package/dist/hosts/integration/support.d.ts +59 -0
- package/dist/hosts/integration/support.js +66 -0
- package/dist/hosts/integration/templates.d.ts +22 -0
- package/dist/hosts/integration/templates.js +75 -0
- package/dist/hosts/pi/protocol.d.ts +22 -0
- package/dist/hosts/pi/protocol.js +28 -0
- package/dist/hosts/pi/query-result.d.ts +22 -0
- package/dist/hosts/pi/query-result.js +710 -0
- package/dist/hosts/pi/rpc.d.ts +939 -0
- package/dist/hosts/pi/rpc.js +1659 -0
- package/dist/hosts/pilot.d.ts +485 -0
- package/dist/hosts/pilot.js +593 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/infra/fs.d.ts +27 -0
- package/dist/infra/fs.js +130 -0
- package/dist/infra/git.d.ts +60 -0
- package/dist/infra/git.js +358 -0
- package/dist/infra/owned-process-group.d.ts +173 -0
- package/dist/infra/owned-process-group.js +571 -0
- package/dist/install/apply.d.ts +65 -0
- package/dist/install/apply.js +663 -0
- package/dist/install/index.d.ts +5 -0
- package/dist/install/index.js +5 -0
- package/dist/install/ownership.d.ts +85 -0
- package/dist/install/ownership.js +430 -0
- package/dist/install/plan.d.ts +39 -0
- package/dist/install/plan.js +97 -0
- package/dist/install/rollback.d.ts +18 -0
- package/dist/install/rollback.js +544 -0
- package/dist/install/runtime.d.ts +76 -0
- package/dist/install/runtime.js +1252 -0
- package/dist/knowledge/catalog.d.ts +47 -0
- package/dist/knowledge/catalog.js +308 -0
- package/dist/knowledge/context.d.ts +28 -0
- package/dist/knowledge/context.js +61 -0
- package/dist/knowledge/index.d.ts +3 -0
- package/dist/knowledge/index.js +1 -0
- package/dist/knowledge/journal.d.ts +16 -0
- package/dist/knowledge/journal.js +109 -0
- package/dist/knowledge/lifecycle.d.ts +8 -0
- package/dist/knowledge/lifecycle.js +1001 -0
- package/dist/knowledge/paths.d.ts +37 -0
- package/dist/knowledge/paths.js +236 -0
- package/dist/knowledge/refs.d.ts +36 -0
- package/dist/knowledge/refs.js +267 -0
- package/dist/knowledge/service.d.ts +21 -0
- package/dist/knowledge/service.js +393 -0
- package/dist/knowledge/types.d.ts +171 -0
- package/dist/knowledge/types.js +1 -0
- package/dist/knowledge/write.d.ts +8 -0
- package/dist/knowledge/write.js +1223 -0
- package/dist/package-info.d.ts +8 -0
- package/dist/package-info.js +25 -0
- package/dist/schemas/code.d.ts +377 -0
- package/dist/schemas/code.js +145 -0
- package/dist/schemas/collaboration.d.ts +115 -0
- package/dist/schemas/collaboration.js +106 -0
- package/dist/schemas/continuity.d.ts +315 -0
- package/dist/schemas/continuity.js +199 -0
- package/dist/schemas/diagnostics.d.ts +28 -0
- package/dist/schemas/diagnostics.js +27 -0
- package/dist/schemas/doctor.d.ts +157 -0
- package/dist/schemas/doctor.js +75 -0
- package/dist/schemas/document.d.ts +644 -0
- package/dist/schemas/document.js +296 -0
- package/dist/schemas/errors.d.ts +177 -0
- package/dist/schemas/errors.js +176 -0
- package/dist/schemas/evidence.d.ts +24 -0
- package/dist/schemas/evidence.js +16 -0
- package/dist/schemas/host.d.ts +436 -0
- package/dist/schemas/host.js +203 -0
- package/dist/schemas/index.d.ts +15 -0
- package/dist/schemas/index.js +15 -0
- package/dist/schemas/init.d.ts +121 -0
- package/dist/schemas/init.js +94 -0
- package/dist/schemas/install.d.ts +227 -0
- package/dist/schemas/install.js +147 -0
- package/dist/schemas/machine.d.ts +43 -0
- package/dist/schemas/machine.js +96 -0
- package/dist/schemas/outcome.d.ts +23 -0
- package/dist/schemas/outcome.js +17 -0
- package/dist/schemas/paths.d.ts +19 -0
- package/dist/schemas/paths.js +63 -0
- package/dist/schemas/workspace.d.ts +120 -0
- package/dist/schemas/workspace.js +201 -0
- package/dist/workspace/config-file.d.ts +36 -0
- package/dist/workspace/config-file.js +237 -0
- package/dist/workspace/config.d.ts +28 -0
- package/dist/workspace/config.js +79 -0
- package/dist/workspace/discover.d.ts +34 -0
- package/dist/workspace/discover.js +195 -0
- package/dist/workspace/documents.d.ts +21 -0
- package/dist/workspace/documents.js +395 -0
- package/dist/workspace/ignore.d.ts +10 -0
- package/dist/workspace/ignore.js +48 -0
- package/dist/workspace/index.d.ts +7 -0
- package/dist/workspace/index.js +3 -0
- package/dist/workspace/repositories.d.ts +24 -0
- package/dist/workspace/repositories.js +411 -0
- package/dist/workspace/resolve.d.ts +24 -0
- package/dist/workspace/resolve.js +268 -0
- package/dist/workspace/types.d.ts +71 -0
- package/dist/workspace/types.js +1 -0
- package/dist/workspace/validation.d.ts +18 -0
- package/dist/workspace/validation.js +197 -0
- package/package.json +111 -4
- package/skills/pappra/SKILL.md +71 -0
- package/skills/pappra/references/hosts.md +40 -0
- package/skills/pappra/references/lifecycle.md +41 -0
- package/skills/pappra/references/operations.md +27 -0
package/dist/cli/run.js
ADDED
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { getPackageInfo } from '../package-info.js';
|
|
3
|
+
import { initUsage, runInitCommand } from './commands/init.js';
|
|
4
|
+
import { doctorUsage, runDoctorCommand } from './commands/doctor.js';
|
|
5
|
+
import { docsUsage, runDocsCommand } from './commands/docs.js';
|
|
6
|
+
import { checkpointUsage, resumeUsage, runCheckpointCommand, runResumeCommand, } from './commands/continuity.js';
|
|
7
|
+
import { codeUsage, runCodeCommand } from './commands/code.js';
|
|
8
|
+
import { collaborationUsage, runCollaborationCommand, } from './commands/collaboration.js';
|
|
9
|
+
import { hostUsage, runHostCommand } from './commands/host.js';
|
|
10
|
+
import { runtimeUsage, runRuntimeCommand } from './commands/runtime.js';
|
|
11
|
+
import { hostNameSchema } from '../schemas/host.js';
|
|
12
|
+
function parseOptions(args) {
|
|
13
|
+
const { values, positionals } = parseArgs({
|
|
14
|
+
args: [...args],
|
|
15
|
+
options: {
|
|
16
|
+
help: { type: 'boolean', short: 'h' },
|
|
17
|
+
version: { type: 'boolean', short: 'v' },
|
|
18
|
+
json: { type: 'boolean' },
|
|
19
|
+
config: { type: 'string' },
|
|
20
|
+
apply: { type: 'boolean' },
|
|
21
|
+
yes: { type: 'boolean', short: 'y' },
|
|
22
|
+
'no-runtime': { type: 'boolean' },
|
|
23
|
+
reconfigure: { type: 'boolean' },
|
|
24
|
+
from: { type: 'string' },
|
|
25
|
+
tarball: { type: 'string' },
|
|
26
|
+
out: { type: 'string' },
|
|
27
|
+
mode: { type: 'string' },
|
|
28
|
+
marketplace: { type: 'boolean' },
|
|
29
|
+
scope: { type: 'string' },
|
|
30
|
+
bind: { type: 'boolean' },
|
|
31
|
+
force: { type: 'boolean' },
|
|
32
|
+
'no-interactive': { type: 'boolean' },
|
|
33
|
+
'print-choices': { type: 'boolean' },
|
|
34
|
+
'install-runtime': { type: 'boolean' },
|
|
35
|
+
'runtime-tarball': { type: 'string' },
|
|
36
|
+
'runtime-version': { type: 'string' },
|
|
37
|
+
root: { type: 'string' },
|
|
38
|
+
'include-private': { type: 'boolean' },
|
|
39
|
+
'include-archived': { type: 'boolean' },
|
|
40
|
+
task: { type: 'string' },
|
|
41
|
+
objective: { type: 'string' },
|
|
42
|
+
acceptance: { type: 'string', multiple: true },
|
|
43
|
+
constraint: { type: 'string', multiple: true },
|
|
44
|
+
decision: { type: 'string', multiple: true },
|
|
45
|
+
attempted: { type: 'string', multiple: true },
|
|
46
|
+
'next-action': { type: 'string', multiple: true },
|
|
47
|
+
limitation: { type: 'string', multiple: true },
|
|
48
|
+
artifact: { type: 'string', multiple: true },
|
|
49
|
+
'collaboration-record': { type: 'string' },
|
|
50
|
+
'context-completeness': { type: 'string' },
|
|
51
|
+
'author-session': { type: 'string' },
|
|
52
|
+
'native-harness': { type: 'string' },
|
|
53
|
+
'native-session': { type: 'string' },
|
|
54
|
+
session: { type: 'string' },
|
|
55
|
+
repo: { type: 'string' },
|
|
56
|
+
kind: { type: 'string' },
|
|
57
|
+
query: { type: 'string' },
|
|
58
|
+
limit: { type: 'string' },
|
|
59
|
+
'max-bytes': { type: 'string' },
|
|
60
|
+
rebuild: { type: 'boolean' },
|
|
61
|
+
host: { type: 'string' },
|
|
62
|
+
'host-root': { type: 'string' },
|
|
63
|
+
'host-version': { type: 'string' },
|
|
64
|
+
goal: { type: 'string' },
|
|
65
|
+
prepared: { type: 'string' },
|
|
66
|
+
capabilities: { type: 'string' },
|
|
67
|
+
controller: { type: 'string' },
|
|
68
|
+
'domain-root': { type: 'string' },
|
|
69
|
+
},
|
|
70
|
+
allowPositionals: true,
|
|
71
|
+
strict: true,
|
|
72
|
+
});
|
|
73
|
+
if (values.help && values.version) {
|
|
74
|
+
throw new Error('Use either --help or --version, not both.');
|
|
75
|
+
}
|
|
76
|
+
const command = positionals[0] ?? null;
|
|
77
|
+
if (command === 'docs') {
|
|
78
|
+
if (positionals.length > 3) {
|
|
79
|
+
throw new Error('Unknown command; docs accepts one action and one argument.');
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
values,
|
|
83
|
+
codeAction: null,
|
|
84
|
+
command,
|
|
85
|
+
docsAction: positionals[1] ?? null,
|
|
86
|
+
docsArgument: positionals[2] ?? null,
|
|
87
|
+
hostAction: null,
|
|
88
|
+
collaborationAction: null,
|
|
89
|
+
resumeTaskId: null,
|
|
90
|
+
runtimeAction: null,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (command === 'resume') {
|
|
94
|
+
if (positionals.length > 2) {
|
|
95
|
+
throw new Error('resume accepts exactly one task id.');
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
values,
|
|
99
|
+
command,
|
|
100
|
+
docsAction: null,
|
|
101
|
+
docsArgument: null,
|
|
102
|
+
codeAction: null,
|
|
103
|
+
hostAction: null,
|
|
104
|
+
collaborationAction: null,
|
|
105
|
+
resumeTaskId: positionals[1] ?? null,
|
|
106
|
+
runtimeAction: null,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (command === 'code') {
|
|
110
|
+
if (positionals.length > 2) {
|
|
111
|
+
throw new Error('code accepts one action: status, prepare, or query.');
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
values,
|
|
115
|
+
command,
|
|
116
|
+
docsAction: null,
|
|
117
|
+
docsArgument: null,
|
|
118
|
+
codeAction: positionals[1] ?? null,
|
|
119
|
+
hostAction: null,
|
|
120
|
+
collaborationAction: null,
|
|
121
|
+
resumeTaskId: null,
|
|
122
|
+
runtimeAction: null,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (command === 'host') {
|
|
126
|
+
if (positionals.length > 2) {
|
|
127
|
+
throw new Error('host accepts one action: detect, describe, plan, install, or verify.');
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
values,
|
|
131
|
+
command,
|
|
132
|
+
docsAction: null,
|
|
133
|
+
docsArgument: null,
|
|
134
|
+
codeAction: null,
|
|
135
|
+
hostAction: positionals[1] ?? null,
|
|
136
|
+
collaborationAction: null,
|
|
137
|
+
resumeTaskId: null,
|
|
138
|
+
runtimeAction: null,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
if (command === 'runtime') {
|
|
142
|
+
if (positionals.length > 2) {
|
|
143
|
+
throw new Error('runtime accepts one action: install, status, verify, or remove.');
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
values,
|
|
147
|
+
command,
|
|
148
|
+
docsAction: null,
|
|
149
|
+
docsArgument: null,
|
|
150
|
+
codeAction: null,
|
|
151
|
+
hostAction: null,
|
|
152
|
+
collaborationAction: null,
|
|
153
|
+
resumeTaskId: null,
|
|
154
|
+
runtimeAction: positionals[1] ?? null,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (command === 'collab') {
|
|
158
|
+
if (positionals.length > 2) {
|
|
159
|
+
throw new Error('collab accepts one action: prepare, run, or query.');
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
values,
|
|
163
|
+
command,
|
|
164
|
+
docsAction: null,
|
|
165
|
+
docsArgument: null,
|
|
166
|
+
codeAction: null,
|
|
167
|
+
hostAction: null,
|
|
168
|
+
collaborationAction: positionals[1] ?? null,
|
|
169
|
+
resumeTaskId: null,
|
|
170
|
+
runtimeAction: null,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (positionals.length > 1) {
|
|
174
|
+
throw new Error('Only one command may be specified.');
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
values,
|
|
178
|
+
command,
|
|
179
|
+
docsAction: null,
|
|
180
|
+
docsArgument: null,
|
|
181
|
+
codeAction: null,
|
|
182
|
+
hostAction: null,
|
|
183
|
+
collaborationAction: null,
|
|
184
|
+
resumeTaskId: null,
|
|
185
|
+
runtimeAction: null,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function failure(output, json, code, error) {
|
|
189
|
+
const message = typeof error === 'string'
|
|
190
|
+
? error
|
|
191
|
+
: error instanceof Error
|
|
192
|
+
? error.message
|
|
193
|
+
: 'Operation failed.';
|
|
194
|
+
if (json) {
|
|
195
|
+
output.stdout(`${JSON.stringify({ ok: false, code, message })}\n`);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
output.stderr(`pappra: ${message}\n`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function hasContinuityOptions(values, includeSession = true) {
|
|
202
|
+
return (values.task !== undefined ||
|
|
203
|
+
values.objective !== undefined ||
|
|
204
|
+
values.acceptance !== undefined ||
|
|
205
|
+
values.constraint !== undefined ||
|
|
206
|
+
values.decision !== undefined ||
|
|
207
|
+
values.attempted !== undefined ||
|
|
208
|
+
values['next-action'] !== undefined ||
|
|
209
|
+
values.limitation !== undefined ||
|
|
210
|
+
values.artifact !== undefined ||
|
|
211
|
+
values['collaboration-record'] !== undefined ||
|
|
212
|
+
values['context-completeness'] !== undefined ||
|
|
213
|
+
values['author-session'] !== undefined ||
|
|
214
|
+
values['native-harness'] !== undefined ||
|
|
215
|
+
values['native-session'] !== undefined ||
|
|
216
|
+
(includeSession && values.session !== undefined));
|
|
217
|
+
}
|
|
218
|
+
const globalUsage = 'pappra [--help | --version] [--json]\n' +
|
|
219
|
+
'pappra init [--config <file> | --yes] [--apply] [--json] [--print-choices]\n' +
|
|
220
|
+
' [--install-runtime (--runtime-tarball <file> | --runtime-version <version>)]\n' +
|
|
221
|
+
'pappra doctor [--root <path>] [--json]\n' +
|
|
222
|
+
'pappra docs <list|check|archive> [options]\n' +
|
|
223
|
+
'pappra checkpoint --task <id> [options] [--json]\n' +
|
|
224
|
+
'pappra resume <taskId> [--session <id>] [--json]\n' +
|
|
225
|
+
'pappra code <status|prepare|query> --repo <id> [options] [--json]\n' +
|
|
226
|
+
'pappra host <detect|describe|plan|install|verify> --host <name> [options] [--json]\n' +
|
|
227
|
+
'pappra runtime <install|status|verify|remove> [options] [--json]\n' +
|
|
228
|
+
'pappra collab <prepare|run|query> [options]';
|
|
229
|
+
export async function runCli(args, output) {
|
|
230
|
+
const jsonRequested = args.includes('--json');
|
|
231
|
+
let parsed;
|
|
232
|
+
try {
|
|
233
|
+
parsed = parseOptions(args);
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
failure(output, jsonRequested, 'invalid_arguments', error);
|
|
237
|
+
return 2;
|
|
238
|
+
}
|
|
239
|
+
const { values, command, docsAction, docsArgument, codeAction, hostAction, collaborationAction, resumeTaskId, runtimeAction, } = parsed;
|
|
240
|
+
const json = values.json === true;
|
|
241
|
+
const applyRequested = values.apply === true;
|
|
242
|
+
if (command !== 'init' &&
|
|
243
|
+
(values.yes === true ||
|
|
244
|
+
values['no-interactive'] === true ||
|
|
245
|
+
values['print-choices'] === true ||
|
|
246
|
+
values['no-runtime'] === true ||
|
|
247
|
+
values.reconfigure === true)) {
|
|
248
|
+
failure(output, json, 'invalid_arguments', '--yes, --no-interactive, --print-choices, --no-runtime and --reconfigure are only valid for init.');
|
|
249
|
+
return 2;
|
|
250
|
+
}
|
|
251
|
+
if (command !== 'host' && values.out !== undefined) {
|
|
252
|
+
failure(output, json, 'invalid_arguments', '--out is only valid for host.');
|
|
253
|
+
return 2;
|
|
254
|
+
}
|
|
255
|
+
if (values.scope !== undefined &&
|
|
256
|
+
values.scope !== 'project' &&
|
|
257
|
+
values.scope !== 'user') {
|
|
258
|
+
failure(output, json, 'invalid_arguments', '--scope accepts project or user.');
|
|
259
|
+
return 2;
|
|
260
|
+
}
|
|
261
|
+
if (command !== 'host' && values.scope !== undefined) {
|
|
262
|
+
failure(output, json, 'invalid_arguments', '--scope is only valid for host.');
|
|
263
|
+
return 2;
|
|
264
|
+
}
|
|
265
|
+
if (command !== 'host' && values.marketplace === true) {
|
|
266
|
+
failure(output, json, 'invalid_arguments', '--marketplace is only valid for host bundle.');
|
|
267
|
+
return 2;
|
|
268
|
+
}
|
|
269
|
+
if (command !== 'host' &&
|
|
270
|
+
values.mode !== undefined &&
|
|
271
|
+
command !== 'runtime') {
|
|
272
|
+
failure(output, json, 'invalid_arguments', '--mode is only valid for host.');
|
|
273
|
+
return 2;
|
|
274
|
+
}
|
|
275
|
+
if (values.mode !== undefined &&
|
|
276
|
+
values.mode !== 'project-settings' &&
|
|
277
|
+
values.mode !== 'plugin') {
|
|
278
|
+
failure(output, json, 'invalid_arguments', '--mode accepts project-settings or plugin.');
|
|
279
|
+
return 2;
|
|
280
|
+
}
|
|
281
|
+
if (command !== 'runtime' &&
|
|
282
|
+
(values.from !== undefined ||
|
|
283
|
+
values.tarball !== undefined ||
|
|
284
|
+
values.bind === true ||
|
|
285
|
+
values.force === true)) {
|
|
286
|
+
failure(output, json, 'invalid_arguments', '--from, --tarball, --bind and --force are only valid for runtime.');
|
|
287
|
+
return 2;
|
|
288
|
+
}
|
|
289
|
+
let info;
|
|
290
|
+
try {
|
|
291
|
+
info = getPackageInfo();
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
failure(output, json, 'package_unavailable', error);
|
|
295
|
+
return 3;
|
|
296
|
+
}
|
|
297
|
+
if (values.version) {
|
|
298
|
+
if (command !== null) {
|
|
299
|
+
failure(output, json, 'invalid_arguments', '--version cannot be combined with a command.');
|
|
300
|
+
return 2;
|
|
301
|
+
}
|
|
302
|
+
output.stdout(json ? `${JSON.stringify(info)}\n` : `${info.version}\n`);
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
if (command === 'collab') {
|
|
306
|
+
if (values.help) {
|
|
307
|
+
if (json) {
|
|
308
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['collab'], usage: collaborationUsage })}\n`);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
output.stdout(collaborationUsage);
|
|
312
|
+
}
|
|
313
|
+
return 0;
|
|
314
|
+
}
|
|
315
|
+
const action = collaborationAction === 'prepare' ||
|
|
316
|
+
collaborationAction === 'run' ||
|
|
317
|
+
collaborationAction === 'query'
|
|
318
|
+
? collaborationAction
|
|
319
|
+
: null;
|
|
320
|
+
if (action === null ||
|
|
321
|
+
values.version ||
|
|
322
|
+
values.config !== undefined ||
|
|
323
|
+
values['install-runtime'] === true ||
|
|
324
|
+
values['runtime-tarball'] !== undefined ||
|
|
325
|
+
values['runtime-version'] !== undefined ||
|
|
326
|
+
values.root !== undefined ||
|
|
327
|
+
values['include-private'] === true ||
|
|
328
|
+
values['include-archived'] === true ||
|
|
329
|
+
hasContinuityOptions(values)) {
|
|
330
|
+
failure(output, json, 'invalid_arguments', 'collab requires prepare/run/query and only collab options.');
|
|
331
|
+
return 2;
|
|
332
|
+
}
|
|
333
|
+
return runCollaborationCommand({
|
|
334
|
+
cwd: process.cwd(),
|
|
335
|
+
action,
|
|
336
|
+
json,
|
|
337
|
+
goalFile: values.goal ?? null,
|
|
338
|
+
preparedFile: values.prepared ?? null,
|
|
339
|
+
capabilitiesFile: values.capabilities ?? null,
|
|
340
|
+
controller: values.controller ?? null,
|
|
341
|
+
domainRoot: values['domain-root'] ?? null,
|
|
342
|
+
}, output);
|
|
343
|
+
}
|
|
344
|
+
if (command === 'docs') {
|
|
345
|
+
if (values.version ||
|
|
346
|
+
values.config !== undefined ||
|
|
347
|
+
values['install-runtime'] === true ||
|
|
348
|
+
values['runtime-tarball'] !== undefined ||
|
|
349
|
+
values['runtime-version'] !== undefined ||
|
|
350
|
+
values.root !== undefined ||
|
|
351
|
+
hasContinuityOptions(values)) {
|
|
352
|
+
failure(output, json, 'invalid_arguments', 'docs only accepts list/check/archive/scan, --include-private, --include-archived, --apply (scan only), --help, and --json.');
|
|
353
|
+
return 2;
|
|
354
|
+
}
|
|
355
|
+
if (values.help) {
|
|
356
|
+
if (json) {
|
|
357
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['docs'], usage: docsUsage })}\n`);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
output.stdout(docsUsage);
|
|
361
|
+
}
|
|
362
|
+
return 0;
|
|
363
|
+
}
|
|
364
|
+
return runDocsCommand({
|
|
365
|
+
cwd: process.cwd(),
|
|
366
|
+
action: docsAction,
|
|
367
|
+
argument: docsArgument,
|
|
368
|
+
json,
|
|
369
|
+
includePrivate: values['include-private'] === true,
|
|
370
|
+
includeArchived: values['include-archived'] === true,
|
|
371
|
+
apply: applyRequested,
|
|
372
|
+
}, output);
|
|
373
|
+
}
|
|
374
|
+
if (command === 'doctor') {
|
|
375
|
+
if (values.help) {
|
|
376
|
+
if (json) {
|
|
377
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['init', 'doctor', 'docs'], usage: doctorUsage })}\n`);
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
output.stdout(doctorUsage);
|
|
381
|
+
}
|
|
382
|
+
return 0;
|
|
383
|
+
}
|
|
384
|
+
if (values.version ||
|
|
385
|
+
values.config !== undefined ||
|
|
386
|
+
values.apply === true ||
|
|
387
|
+
values['install-runtime'] === true ||
|
|
388
|
+
values['runtime-tarball'] !== undefined ||
|
|
389
|
+
values['runtime-version'] !== undefined ||
|
|
390
|
+
values['include-private'] === true ||
|
|
391
|
+
values['include-archived'] === true ||
|
|
392
|
+
hasContinuityOptions(values)) {
|
|
393
|
+
failure(output, json, 'invalid_arguments', 'doctor only accepts --root, --help, and --json.');
|
|
394
|
+
return 2;
|
|
395
|
+
}
|
|
396
|
+
return runDoctorCommand({
|
|
397
|
+
root: values.root ?? process.cwd(),
|
|
398
|
+
json,
|
|
399
|
+
}, output);
|
|
400
|
+
}
|
|
401
|
+
if (command === 'init') {
|
|
402
|
+
if (values.root !== undefined ||
|
|
403
|
+
values['include-private'] === true ||
|
|
404
|
+
values['include-archived'] === true ||
|
|
405
|
+
hasContinuityOptions(values)) {
|
|
406
|
+
failure(output, json, 'invalid_arguments', '--root, --include-private, and --include-archived are not valid for init; init uses the current directory.');
|
|
407
|
+
return 2;
|
|
408
|
+
}
|
|
409
|
+
if (values.help) {
|
|
410
|
+
if (json) {
|
|
411
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['init'], usage: initUsage })}\n`);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
output.stdout(initUsage);
|
|
415
|
+
}
|
|
416
|
+
return 0;
|
|
417
|
+
}
|
|
418
|
+
if (values.version) {
|
|
419
|
+
failure(output, json, 'invalid_arguments', '--version cannot be combined with init.');
|
|
420
|
+
return 2;
|
|
421
|
+
}
|
|
422
|
+
return runInitCommand({
|
|
423
|
+
cwd: process.cwd(),
|
|
424
|
+
configPath: values.config ?? null,
|
|
425
|
+
apply: values.apply === true,
|
|
426
|
+
json,
|
|
427
|
+
installRuntime: values['install-runtime'] === true,
|
|
428
|
+
runtimeTarball: values['runtime-tarball'] ?? null,
|
|
429
|
+
runtimeVersion: values['runtime-version'] ?? null,
|
|
430
|
+
yes: values.yes === true || values['no-interactive'] === true,
|
|
431
|
+
printChoices: values['print-choices'] === true,
|
|
432
|
+
noRuntime: values['no-runtime'] === true,
|
|
433
|
+
reconfigure: values.reconfigure === true,
|
|
434
|
+
}, output);
|
|
435
|
+
}
|
|
436
|
+
if (command === 'runtime') {
|
|
437
|
+
if (values.help) {
|
|
438
|
+
if (json) {
|
|
439
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['runtime'], usage: runtimeUsage })}\n`);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
output.stdout(runtimeUsage);
|
|
443
|
+
}
|
|
444
|
+
return 0;
|
|
445
|
+
}
|
|
446
|
+
if (values.version ||
|
|
447
|
+
values.config !== undefined ||
|
|
448
|
+
values['install-runtime'] === true ||
|
|
449
|
+
values['runtime-tarball'] !== undefined ||
|
|
450
|
+
values.root !== undefined ||
|
|
451
|
+
values.host !== undefined ||
|
|
452
|
+
values.repo !== undefined ||
|
|
453
|
+
values.query !== undefined ||
|
|
454
|
+
values.kind !== undefined ||
|
|
455
|
+
hasContinuityOptions(values)) {
|
|
456
|
+
failure(output, json, 'invalid_arguments', 'runtime accepts only --from, --tarball, --version, --apply, --bind, --force, --help, and --json.');
|
|
457
|
+
return 2;
|
|
458
|
+
}
|
|
459
|
+
const action = runtimeAction === 'install' ||
|
|
460
|
+
runtimeAction === 'status' ||
|
|
461
|
+
runtimeAction === 'verify' ||
|
|
462
|
+
runtimeAction === 'remove'
|
|
463
|
+
? runtimeAction
|
|
464
|
+
: null;
|
|
465
|
+
return runRuntimeCommand({
|
|
466
|
+
cwd: process.cwd(),
|
|
467
|
+
action,
|
|
468
|
+
json,
|
|
469
|
+
from: values.from === 'self' ||
|
|
470
|
+
values.from === 'tarball' ||
|
|
471
|
+
values.from === 'registry'
|
|
472
|
+
? values.from
|
|
473
|
+
: null,
|
|
474
|
+
tarball: values.tarball ?? null,
|
|
475
|
+
version: values['runtime-version'] ?? null,
|
|
476
|
+
apply: values.apply === true,
|
|
477
|
+
bind: values.bind === true,
|
|
478
|
+
force: values.force === true,
|
|
479
|
+
}, output);
|
|
480
|
+
}
|
|
481
|
+
if (command === 'checkpoint') {
|
|
482
|
+
if (values.help) {
|
|
483
|
+
if (json) {
|
|
484
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['checkpoint', 'resume'], usage: checkpointUsage })}\n`);
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
output.stdout(checkpointUsage);
|
|
488
|
+
}
|
|
489
|
+
return 0;
|
|
490
|
+
}
|
|
491
|
+
if (values.version ||
|
|
492
|
+
values.config !== undefined ||
|
|
493
|
+
values.apply === true ||
|
|
494
|
+
values['install-runtime'] === true ||
|
|
495
|
+
values['runtime-tarball'] !== undefined ||
|
|
496
|
+
values['runtime-version'] !== undefined ||
|
|
497
|
+
values.root !== undefined ||
|
|
498
|
+
values['include-private'] === true ||
|
|
499
|
+
values['include-archived'] === true ||
|
|
500
|
+
values.session !== undefined ||
|
|
501
|
+
values.task === undefined) {
|
|
502
|
+
failure(output, json, 'invalid_arguments', 'checkpoint requires --task and accepts only task/context options.');
|
|
503
|
+
return 2;
|
|
504
|
+
}
|
|
505
|
+
const completeness = values['context-completeness'];
|
|
506
|
+
if (completeness !== undefined &&
|
|
507
|
+
completeness !== 'complete' &&
|
|
508
|
+
completeness !== 'partial') {
|
|
509
|
+
failure(output, json, 'invalid_arguments', '--context-completeness must be complete or partial.');
|
|
510
|
+
return 2;
|
|
511
|
+
}
|
|
512
|
+
const nativeHarnessValue = values['native-harness'];
|
|
513
|
+
if (nativeHarnessValue !== undefined &&
|
|
514
|
+
!['pi', 'codex', 'claude', 'unknown'].includes(nativeHarnessValue)) {
|
|
515
|
+
failure(output, json, 'invalid_arguments', '--native-harness must be pi, codex, claude, or unknown.');
|
|
516
|
+
return 2;
|
|
517
|
+
}
|
|
518
|
+
const nativeHarness = nativeHarnessValue === 'pi' ||
|
|
519
|
+
nativeHarnessValue === 'codex' ||
|
|
520
|
+
nativeHarnessValue === 'claude' ||
|
|
521
|
+
nativeHarnessValue === 'unknown'
|
|
522
|
+
? nativeHarnessValue
|
|
523
|
+
: null;
|
|
524
|
+
return runCheckpointCommand({
|
|
525
|
+
cwd: process.cwd(),
|
|
526
|
+
json,
|
|
527
|
+
task: values.task,
|
|
528
|
+
objective: values.objective ?? null,
|
|
529
|
+
acceptance: values.acceptance ?? [],
|
|
530
|
+
constraints: values.constraint ?? [],
|
|
531
|
+
decisions: values.decision ?? [],
|
|
532
|
+
attempted: values.attempted ?? [],
|
|
533
|
+
nextActions: values['next-action'] ?? [],
|
|
534
|
+
limitations: values.limitation ?? [],
|
|
535
|
+
artifacts: values.artifact ?? [],
|
|
536
|
+
collaborationRecordRef: values['collaboration-record'] ?? null,
|
|
537
|
+
contextCompleteness: completeness ?? null,
|
|
538
|
+
authorSession: values['author-session'] ?? process.env.PI_SESSION_ID ?? null,
|
|
539
|
+
nativeHarness: nativeHarness ?? null,
|
|
540
|
+
nativeSession: values['native-session'] ?? null,
|
|
541
|
+
}, output);
|
|
542
|
+
}
|
|
543
|
+
if (command === 'resume') {
|
|
544
|
+
if (values.help) {
|
|
545
|
+
if (json) {
|
|
546
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['checkpoint', 'resume'], usage: resumeUsage })}\n`);
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
output.stdout(resumeUsage);
|
|
550
|
+
}
|
|
551
|
+
return 0;
|
|
552
|
+
}
|
|
553
|
+
if (values.version ||
|
|
554
|
+
values.config !== undefined ||
|
|
555
|
+
values.apply === true ||
|
|
556
|
+
values['install-runtime'] === true ||
|
|
557
|
+
values['runtime-tarball'] !== undefined ||
|
|
558
|
+
values['runtime-version'] !== undefined ||
|
|
559
|
+
values.root !== undefined ||
|
|
560
|
+
values['include-private'] === true ||
|
|
561
|
+
values['include-archived'] === true ||
|
|
562
|
+
hasContinuityOptions(values, false) ||
|
|
563
|
+
resumeTaskId === null) {
|
|
564
|
+
failure(output, json, 'invalid_arguments', 'resume requires one task id and accepts only --session.');
|
|
565
|
+
return 2;
|
|
566
|
+
}
|
|
567
|
+
return runResumeCommand({
|
|
568
|
+
cwd: process.cwd(),
|
|
569
|
+
json,
|
|
570
|
+
taskId: resumeTaskId,
|
|
571
|
+
currentSession: values.session ?? process.env.PI_SESSION_ID ?? null,
|
|
572
|
+
}, output);
|
|
573
|
+
}
|
|
574
|
+
if (command === 'code') {
|
|
575
|
+
if (values.help) {
|
|
576
|
+
if (json) {
|
|
577
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['code'], usage: codeUsage })}\n`);
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
output.stdout(codeUsage);
|
|
581
|
+
}
|
|
582
|
+
return 0;
|
|
583
|
+
}
|
|
584
|
+
const allowedActions = ['status', 'prepare', 'query'];
|
|
585
|
+
const action = allowedActions.find((item) => item === codeAction) ?? null;
|
|
586
|
+
const kindValues = [
|
|
587
|
+
'explore',
|
|
588
|
+
'symbol',
|
|
589
|
+
'references',
|
|
590
|
+
'impact',
|
|
591
|
+
'text',
|
|
592
|
+
];
|
|
593
|
+
const kind = kindValues.find((item) => item === values.kind) ?? null;
|
|
594
|
+
const operationsInvalid = values.version ||
|
|
595
|
+
values.config !== undefined ||
|
|
596
|
+
values['install-runtime'] === true ||
|
|
597
|
+
values['runtime-tarball'] !== undefined ||
|
|
598
|
+
values['runtime-version'] !== undefined ||
|
|
599
|
+
values.root !== undefined ||
|
|
600
|
+
values['include-private'] === true ||
|
|
601
|
+
values['include-archived'] === true ||
|
|
602
|
+
hasContinuityOptions(values);
|
|
603
|
+
if (action === null ||
|
|
604
|
+
values.repo === undefined ||
|
|
605
|
+
operationsInvalid ||
|
|
606
|
+
(values.apply === true && action !== 'prepare') ||
|
|
607
|
+
(values.rebuild === true && action !== 'prepare') ||
|
|
608
|
+
(action !== 'query' &&
|
|
609
|
+
(values.kind !== undefined ||
|
|
610
|
+
values.query !== undefined ||
|
|
611
|
+
values.limit !== undefined ||
|
|
612
|
+
values['max-bytes'] !== undefined)) ||
|
|
613
|
+
(action !== 'prepare' && values.rebuild === true) ||
|
|
614
|
+
(action !== 'prepare' && values.apply === true)) {
|
|
615
|
+
failure(output, json, 'invalid_arguments', 'code requires status/prepare/query, --repo, and action-compatible options.');
|
|
616
|
+
return 2;
|
|
617
|
+
}
|
|
618
|
+
if (action === 'query' && (kind === null || values.query === undefined)) {
|
|
619
|
+
failure(output, json, 'invalid_arguments', 'code query requires --kind explore|symbol|references|impact|text and --query.');
|
|
620
|
+
return 2;
|
|
621
|
+
}
|
|
622
|
+
const numberOption = (raw, minimum, maximum) => {
|
|
623
|
+
if (raw === undefined)
|
|
624
|
+
return null;
|
|
625
|
+
const value = Number(raw);
|
|
626
|
+
return Number.isSafeInteger(value) && value >= minimum && value <= maximum
|
|
627
|
+
? value
|
|
628
|
+
: undefined;
|
|
629
|
+
};
|
|
630
|
+
const maxResults = numberOption(values.limit, 1, 100);
|
|
631
|
+
const maxBytes = numberOption(values['max-bytes'], 1, 16 * 1024 * 1024);
|
|
632
|
+
if (maxResults === undefined || maxBytes === undefined) {
|
|
633
|
+
failure(output, json, 'invalid_arguments', '--limit must be 1-100 and --max-bytes must be 1-16777216.');
|
|
634
|
+
return 2;
|
|
635
|
+
}
|
|
636
|
+
return runCodeCommand({
|
|
637
|
+
cwd: process.cwd(),
|
|
638
|
+
json,
|
|
639
|
+
action,
|
|
640
|
+
repositoryId: values.repo,
|
|
641
|
+
kind: action === 'query' ? kind : null,
|
|
642
|
+
query: action === 'query' ? (values.query ?? null) : null,
|
|
643
|
+
maxResults,
|
|
644
|
+
maxBytes,
|
|
645
|
+
apply: values.apply === true,
|
|
646
|
+
rebuild: values.rebuild === true,
|
|
647
|
+
}, output);
|
|
648
|
+
}
|
|
649
|
+
if (command === 'host') {
|
|
650
|
+
const allowedActions = [
|
|
651
|
+
'detect',
|
|
652
|
+
'describe',
|
|
653
|
+
'plan',
|
|
654
|
+
'install',
|
|
655
|
+
'verify',
|
|
656
|
+
'bundle',
|
|
657
|
+
];
|
|
658
|
+
const action = allowedActions.find((item) => item === hostAction) ?? null;
|
|
659
|
+
const parsedHost = hostNameSchema.safeParse(values.host);
|
|
660
|
+
const host = parsedHost.success ? parsedHost.data : null;
|
|
661
|
+
const invalid = values.version ||
|
|
662
|
+
values.config !== undefined ||
|
|
663
|
+
values['install-runtime'] === true ||
|
|
664
|
+
values['runtime-tarball'] !== undefined ||
|
|
665
|
+
values['runtime-version'] !== undefined ||
|
|
666
|
+
values.root !== undefined ||
|
|
667
|
+
values['include-private'] === true ||
|
|
668
|
+
values['include-archived'] === true ||
|
|
669
|
+
values.repo !== undefined ||
|
|
670
|
+
values.kind !== undefined ||
|
|
671
|
+
values.query !== undefined ||
|
|
672
|
+
values.limit !== undefined ||
|
|
673
|
+
values['max-bytes'] !== undefined ||
|
|
674
|
+
values.rebuild === true ||
|
|
675
|
+
hasContinuityOptions(values) ||
|
|
676
|
+
(values.apply === true && action !== 'install') ||
|
|
677
|
+
(values.mode !== undefined && action !== 'install') ||
|
|
678
|
+
(values.marketplace === true && action !== 'bundle') ||
|
|
679
|
+
(values.scope !== undefined &&
|
|
680
|
+
action !== 'plan' &&
|
|
681
|
+
action !== 'install' &&
|
|
682
|
+
action !== 'verify') ||
|
|
683
|
+
(values['host-root'] !== undefined && action === null) ||
|
|
684
|
+
(values['host-version'] !== undefined && action === null);
|
|
685
|
+
if (values.help) {
|
|
686
|
+
if (json) {
|
|
687
|
+
output.stdout(`${JSON.stringify({ ...info, commands: ['host'], usage: hostUsage })}\n`);
|
|
688
|
+
}
|
|
689
|
+
else {
|
|
690
|
+
output.stdout(hostUsage);
|
|
691
|
+
}
|
|
692
|
+
return 0;
|
|
693
|
+
}
|
|
694
|
+
if (action === null || host === null || invalid) {
|
|
695
|
+
failure(output, json, 'invalid_arguments', 'host requires detect/describe/plan/install/verify/bundle, --host, and action-compatible options.');
|
|
696
|
+
return 2;
|
|
697
|
+
}
|
|
698
|
+
return runHostCommand({
|
|
699
|
+
cwd: process.cwd(),
|
|
700
|
+
json,
|
|
701
|
+
action,
|
|
702
|
+
host,
|
|
703
|
+
hostRoot: values['host-root'] ?? null,
|
|
704
|
+
hostVersion: values['host-version'] ?? null,
|
|
705
|
+
apply: values.apply === true,
|
|
706
|
+
out: values.out ?? null,
|
|
707
|
+
mode: values.mode === 'project-settings' || values.mode === 'plugin'
|
|
708
|
+
? values.mode
|
|
709
|
+
: null,
|
|
710
|
+
marketplace: values.marketplace === true,
|
|
711
|
+
scope: values.scope === 'project' || values.scope === 'user'
|
|
712
|
+
? values.scope
|
|
713
|
+
: null,
|
|
714
|
+
}, output);
|
|
715
|
+
}
|
|
716
|
+
if (command !== null) {
|
|
717
|
+
failure(output, json, 'invalid_arguments', `Unknown command: ${command}`);
|
|
718
|
+
return 2;
|
|
719
|
+
}
|
|
720
|
+
if (values.config !== undefined ||
|
|
721
|
+
values.apply === true ||
|
|
722
|
+
values['install-runtime'] === true ||
|
|
723
|
+
values['runtime-tarball'] !== undefined ||
|
|
724
|
+
values['runtime-version'] !== undefined ||
|
|
725
|
+
values.root !== undefined ||
|
|
726
|
+
values['include-private'] === true ||
|
|
727
|
+
values['include-archived'] === true ||
|
|
728
|
+
hasContinuityOptions(values)) {
|
|
729
|
+
failure(output, json, 'invalid_arguments', '--config/--apply/runtime flags require init; --root requires doctor.');
|
|
730
|
+
return 2;
|
|
731
|
+
}
|
|
732
|
+
if (values.help) {
|
|
733
|
+
if (json) {
|
|
734
|
+
output.stdout(`${JSON.stringify({ ...info, usage: globalUsage, commands: ['init', 'doctor', 'docs', 'checkpoint', 'resume', 'code', 'host', 'collab'] })}\n`);
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
output.stdout(`${info.name} ${info.version}\n${info.description}\n\nUsage:\n ${globalUsage.replaceAll('\n', '\n ')}\n\nOptions:\n -h, --help Show help\n -v, --version Show version\n --json Output JSON\n\nCommands:\n init Plan workspace initialization\n doctor Read-only workspace and installation diagnostics\n docs List, check, and archive registered documents\n`);
|
|
738
|
+
output.stdout(' checkpoint Save a private task checkpoint\n resume Read a bounded recovery packet without starting an agent\n code Inspect or prepare selected code intelligence\n host Detect, plan, install, or verify a selected host integration\n collab Prepare, run, or query a bounded collaboration goal\n');
|
|
739
|
+
}
|
|
740
|
+
return 0;
|
|
741
|
+
}
|
|
742
|
+
if (json) {
|
|
743
|
+
output.stdout(`${JSON.stringify({ ...info, usage: globalUsage, commands: ['init', 'doctor', 'docs', 'checkpoint', 'resume', 'code', 'host', 'collab'] })}\n`);
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
output.stdout(`${info.name} ${info.version}\n${info.description}\n\nUsage:\n ${globalUsage}\n\nRun pappra --help for all options.\n`);
|
|
747
|
+
}
|
|
748
|
+
return 0;
|
|
749
|
+
}
|