cowork-flow 2.4.2 → 2.5.2
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/CHANGELOG.md +44 -1
- package/CONTRIBUTING.en.md +115 -0
- package/CONTRIBUTING.md +14 -8
- package/README.en.md +14 -3
- package/README.md +10 -2
- package/docs/architecture.en.md +2 -0
- package/docs/architecture.md +2 -0
- package/docs/hosts.en.md +15 -0
- package/docs/hosts.md +15 -0
- package/docs/index.en.md +1 -1
- package/docs/release.en.md +1 -1
- package/package.json +4 -3
- package/presets/claude-code/.claude-plugin/plugin.json +1 -1
- package/presets/codex/.codex-plugin/plugin.json +1 -1
- package/presets/kimi-code/.kimi-plugin/plugin.json +1 -1
- package/presets/qoder/.qoder-plugin/plugin.json +1 -1
- package/presets/zcode/.zcode-plugin/plugin.json +1 -1
- package/src/commands/host-inspect.js +86 -0
- package/src/commands/host.js +42 -18
- package/src/commands/init.js +111 -5
- package/src/commands/install-claude-code-plugin.js +53 -2
- package/src/commands/install-codex-plugin.js +114 -4
- package/src/commands/install-dsh-hook.js +51 -0
- package/src/commands/install-dsh-preset.js +56 -9
- package/src/commands/install-kimi-code-plugin.js +61 -2
- package/src/commands/install-kimi-hook.js +84 -2
- package/src/commands/install-opencode-plugin.js +58 -2
- package/src/commands/install-qoder-plugin.js +67 -3
- package/src/commands/install-zcode-plugin.js +77 -2
- package/src/commands/registry.js +20 -5
- package/src/lib/dsh-home.js +2 -2
- package/template/.cowork-flow/.version +1 -1
- package/template/.cowork-flow/scripts/adapters/cli/task_navigation.py +8 -3
- package/template/.cowork-flow/scripts/adapters/host/host_manifest.py +4 -0
- package/template/.cowork-flow/scripts/adapters/host/workflow_state_hook.py +1 -3
- package/template/.cowork-flow/scripts/infra/files.py +0 -13
- package/template/.cowork-flow/scripts/services/ac_evidence.py +1 -1
- package/template/.cowork-flow/scripts/services/decision_anchor_schema.py +65 -0
- package/template/.cowork-flow/scripts/services/fact_view.py +2 -75
- package/template/.cowork-flow/scripts/services/lifecycle_checks.py +1 -1
- package/template/.cowork-flow/scripts/services/plan_readiness.py +139 -67
- package/template/.cowork-flow/spec/contracts/host-install-inspection.md +174 -0
- package/template/.cowork-flow/spec/contracts/index.md +1 -0
- package/template/.cowork-flow/spec/runtime/contract-registry.json +15 -0
- package/template/skills/runtime-health/scripts/doctor.py +538 -489
- package/template/skills/task-review/scripts/review_check.py +33 -6
package/src/commands/host.js
CHANGED
|
@@ -3,15 +3,16 @@ import { join, resolve } from 'node:path';
|
|
|
3
3
|
import { UsageError, extractValueFlag, parseFlags } from '../lib/cli-flags.js';
|
|
4
4
|
import { hostRegistry } from '../lib/host-assets.js';
|
|
5
5
|
import { pathExists } from '../lib/install-support.js';
|
|
6
|
-
import { runInstallCodexPlugin, FLAGS as CODEX_PLUGIN_FLAGS } from './install-codex-plugin.js';
|
|
7
|
-
import { runInstallClaudeCodePlugin, FLAGS as CLAUDE_CODE_PLUGIN_FLAGS } from './install-claude-code-plugin.js';
|
|
8
|
-
import { runInstallDshHook, FLAGS as DSH_HOOK_FLAGS } from './install-dsh-hook.js';
|
|
9
|
-
import { runInstallDshPreset, FLAGS as DSH_PRESET_FLAGS } from './install-dsh-preset.js';
|
|
10
|
-
import { runInstallKimiPlugin, FLAGS as KIMI_PLUGIN_FLAGS } from './install-kimi-code-plugin.js';
|
|
11
|
-
import { runInstallKimiHook, FLAGS as KIMI_HOOK_FLAGS } from './install-kimi-hook.js';
|
|
12
|
-
import { runInstallOpenCodePlugin, FLAGS as OPENCODE_PLUGIN_FLAGS } from './install-opencode-plugin.js';
|
|
13
|
-
import { runInstallQoderPlugin, FLAGS as QODER_PLUGIN_FLAGS } from './install-qoder-plugin.js';
|
|
14
|
-
import { runInstallZCodePlugin, FLAGS as ZCODE_PLUGIN_FLAGS } from './install-zcode-plugin.js';
|
|
6
|
+
import { runInstallCodexPlugin, inspectInstalledState as inspectCodex, FLAGS as CODEX_PLUGIN_FLAGS } from './install-codex-plugin.js';
|
|
7
|
+
import { runInstallClaudeCodePlugin, inspectInstalledState as inspectClaude, FLAGS as CLAUDE_CODE_PLUGIN_FLAGS } from './install-claude-code-plugin.js';
|
|
8
|
+
import { runInstallDshHook, inspectInstalledState as inspectDshHook, FLAGS as DSH_HOOK_FLAGS } from './install-dsh-hook.js';
|
|
9
|
+
import { runInstallDshPreset, inspectInstalledState as inspectDshPreset, FLAGS as DSH_PRESET_FLAGS } from './install-dsh-preset.js';
|
|
10
|
+
import { runInstallKimiPlugin, inspectInstalledState as inspectKimiPlugin, FLAGS as KIMI_PLUGIN_FLAGS } from './install-kimi-code-plugin.js';
|
|
11
|
+
import { runInstallKimiHook, inspectInstalledState as inspectKimiHook, FLAGS as KIMI_HOOK_FLAGS } from './install-kimi-hook.js';
|
|
12
|
+
import { runInstallOpenCodePlugin, inspectInstalledState as inspectOpenCode, FLAGS as OPENCODE_PLUGIN_FLAGS } from './install-opencode-plugin.js';
|
|
13
|
+
import { runInstallQoderPlugin, inspectInstalledState as inspectQoder, FLAGS as QODER_PLUGIN_FLAGS } from './install-qoder-plugin.js';
|
|
14
|
+
import { runInstallZCodePlugin, inspectInstalledState as inspectZCode, FLAGS as ZCODE_PLUGIN_FLAGS } from './install-zcode-plugin.js';
|
|
15
|
+
import { inspectHosts, renderInspectLine } from './host-inspect.js';
|
|
15
16
|
|
|
16
17
|
const KIMI_ALL_FLAGS = [...new Set([...KIMI_HOOK_FLAGS, ...KIMI_PLUGIN_FLAGS])].sort();
|
|
17
18
|
|
|
@@ -25,45 +26,45 @@ export const HOST_COMPONENTS = {
|
|
|
25
26
|
codex: {
|
|
26
27
|
default: 'plugin',
|
|
27
28
|
components: {
|
|
28
|
-
plugin: { summary: 'Codex plugin: marketplace source plus the bootstrap skill', flags: CODEX_PLUGIN_FLAGS, run: runInstallCodexPlugin }
|
|
29
|
+
plugin: { summary: 'Codex plugin: marketplace source plus the bootstrap skill', flags: CODEX_PLUGIN_FLAGS, run: runInstallCodexPlugin, inspect: inspectCodex }
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
32
|
'claude-code': {
|
|
32
33
|
default: 'plugin',
|
|
33
34
|
components: {
|
|
34
|
-
plugin: { summary: 'Claude Code skills-directory plugin: the bootstrap skill', flags: CLAUDE_CODE_PLUGIN_FLAGS, run: runInstallClaudeCodePlugin }
|
|
35
|
+
plugin: { summary: 'Claude Code skills-directory plugin: the bootstrap skill', flags: CLAUDE_CODE_PLUGIN_FLAGS, run: runInstallClaudeCodePlugin, inspect: inspectClaude }
|
|
35
36
|
}
|
|
36
37
|
},
|
|
37
38
|
opencode: {
|
|
38
39
|
default: 'plugin',
|
|
39
40
|
components: {
|
|
40
|
-
plugin: { summary: 'OpenCode plugin: the plugin file plus the bootstrap skill it registers', flags: OPENCODE_PLUGIN_FLAGS, run: runInstallOpenCodePlugin }
|
|
41
|
+
plugin: { summary: 'OpenCode plugin: the plugin file plus the bootstrap skill it registers', flags: OPENCODE_PLUGIN_FLAGS, run: runInstallOpenCodePlugin, inspect: inspectOpenCode }
|
|
41
42
|
}
|
|
42
43
|
},
|
|
43
44
|
zcode: {
|
|
44
45
|
default: 'plugin',
|
|
45
46
|
components: {
|
|
46
|
-
plugin: { summary: 'ZCode plugin: hooks, agents and the bootstrap skill', flags: ZCODE_PLUGIN_FLAGS, run: runInstallZCodePlugin }
|
|
47
|
+
plugin: { summary: 'ZCode plugin: hooks, agents and the bootstrap skill', flags: ZCODE_PLUGIN_FLAGS, run: runInstallZCodePlugin, inspect: inspectZCode }
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
50
|
qoder: {
|
|
50
51
|
default: 'plugin',
|
|
51
52
|
components: {
|
|
52
|
-
plugin: { summary: 'Qoder plugin: payload, registry entry and enable flag', flags: QODER_PLUGIN_FLAGS, run: runInstallQoderPlugin }
|
|
53
|
+
plugin: { summary: 'Qoder plugin: payload, registry entry and enable flag', flags: QODER_PLUGIN_FLAGS, run: runInstallQoderPlugin, inspect: inspectQoder }
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
56
|
dsh: {
|
|
56
57
|
default: 'preset',
|
|
57
58
|
components: {
|
|
58
|
-
preset: { summary: 'DSH agent preset (bundles the hook, the primary path)', flags: DSH_PRESET_FLAGS, run: runInstallDshPreset },
|
|
59
|
-
hook: { summary: 'DSH workflow-state hook as a machine-level patch row', flags: DSH_HOOK_FLAGS, run: runInstallDshHook }
|
|
59
|
+
preset: { summary: 'DSH agent preset (bundles the hook, the primary path)', flags: DSH_PRESET_FLAGS, run: runInstallDshPreset, inspect: inspectDshPreset },
|
|
60
|
+
hook: { summary: 'DSH workflow-state hook as a machine-level patch row', flags: DSH_HOOK_FLAGS, run: runInstallDshHook, inspect: inspectDshHook }
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
63
|
'kimi-code': {
|
|
63
64
|
default: 'all',
|
|
64
65
|
components: {
|
|
65
|
-
plugin: { summary: 'Kimi Code plugin: the bootstrap Skill it loads at session start', flags: KIMI_PLUGIN_FLAGS, run: runInstallKimiPlugin },
|
|
66
|
-
hook: { summary: 'Kimi Code context-injection hook as a user-level config.toml [[hooks]] row', flags: KIMI_HOOK_FLAGS, run: runInstallKimiHook },
|
|
66
|
+
plugin: { summary: 'Kimi Code plugin: the bootstrap Skill it loads at session start', flags: KIMI_PLUGIN_FLAGS, run: runInstallKimiPlugin, inspect: inspectKimiPlugin },
|
|
67
|
+
hook: { summary: 'Kimi Code context-injection hook as a user-level config.toml [[hooks]] row', flags: KIMI_HOOK_FLAGS, run: runInstallKimiHook, inspect: inspectKimiHook },
|
|
67
68
|
all: { summary: 'Kimi Code hook plus plugin, installed in one command (the default)', flags: KIMI_ALL_FLAGS, run: runInstallKimiAll }
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -151,6 +152,29 @@ export async function runHostRemove(args = []) {
|
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
|
|
155
|
+
// Read-only inspection of machine-level installs. The installer for each host
|
|
156
|
+
// owns its layout; this command only asks and renders the normalized facts.
|
|
157
|
+
export async function runHostInspect(args = [], { io, env = process.env } = {}) {
|
|
158
|
+
const { flags, positionals } = parseFlags(args, {
|
|
159
|
+
boolean: ['--json'],
|
|
160
|
+
positional: { max: 1, name: '[host]' }
|
|
161
|
+
});
|
|
162
|
+
const hostIds = positionals[0] === undefined
|
|
163
|
+
? [...hostRegistry.platformIds]
|
|
164
|
+
: [resolveHost(positionals[0]).id];
|
|
165
|
+
|
|
166
|
+
const report = await inspectHosts(HOST_COMPONENTS, hostIds, { env });
|
|
167
|
+
if (flags['--json']) {
|
|
168
|
+
io.writeOut(`${JSON.stringify(report, null, 2)}\n`);
|
|
169
|
+
return 0;
|
|
170
|
+
}
|
|
171
|
+
for (const row of report.hosts) {
|
|
172
|
+
io.writeOut(renderInspectLine(row));
|
|
173
|
+
}
|
|
174
|
+
return 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
154
178
|
export async function runHostList(args = [], { io } = {}) {
|
|
155
179
|
const { flags, positionals } = parseFlags(args, {
|
|
156
180
|
boolean: ['--json'],
|
package/src/commands/init.js
CHANGED
|
@@ -109,6 +109,102 @@ async function readGitDeveloper(target) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
// `init` itself only needs Node, but the generated project runs on the
|
|
113
|
+
// Python runner. Probe the same candidate order template/.cowork-flow/run
|
|
114
|
+
// uses so a missing interpreter is reported here instead of at first use.
|
|
115
|
+
const PYTHON_VERSION_PROBE = "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}'); "
|
|
116
|
+
+ 'raise SystemExit(0 if sys.version_info >= (3, 10) else 1)';
|
|
117
|
+
|
|
118
|
+
function pythonCandidates(env) {
|
|
119
|
+
for (const name of ['COWORK_FLOW_PYTHON', 'PYTHON']) {
|
|
120
|
+
const value = String(env[name] ?? '').trim();
|
|
121
|
+
if (value) {
|
|
122
|
+
// An explicit override is authoritative: the runner fails instead of
|
|
123
|
+
// falling through to another interpreter.
|
|
124
|
+
return [{ explicit: name, command: value, args: [] }];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return [
|
|
128
|
+
{ explicit: null, command: 'python3', args: [] },
|
|
129
|
+
{ explicit: null, command: 'python', args: [] },
|
|
130
|
+
{ explicit: null, command: 'py', args: ['-3'] }
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function pythonVersionFrom(stdout) {
|
|
135
|
+
const match = /^(\d+\.\d+)/m.exec(String(stdout ?? ''));
|
|
136
|
+
return match ? match[1] : null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function probePython({ env = process.env } = {}) {
|
|
140
|
+
let older = null;
|
|
141
|
+
for (const candidate of pythonCandidates(env)) {
|
|
142
|
+
try {
|
|
143
|
+
const { stdout } = await execFileAsync(
|
|
144
|
+
candidate.command,
|
|
145
|
+
[...candidate.args, '-c', PYTHON_VERSION_PROBE],
|
|
146
|
+
{ timeout: 5000, windowsHide: true }
|
|
147
|
+
);
|
|
148
|
+
return {
|
|
149
|
+
found: true,
|
|
150
|
+
version: pythonVersionFrom(stdout),
|
|
151
|
+
command: candidate.command,
|
|
152
|
+
explicit: candidate.explicit,
|
|
153
|
+
tooOld: false
|
|
154
|
+
};
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (error && error.code === 1) {
|
|
157
|
+
older = {
|
|
158
|
+
version: pythonVersionFrom(error.stdout),
|
|
159
|
+
command: candidate.command,
|
|
160
|
+
explicit: candidate.explicit
|
|
161
|
+
};
|
|
162
|
+
if (candidate.explicit) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (candidate.explicit) {
|
|
168
|
+
return {
|
|
169
|
+
found: false,
|
|
170
|
+
version: null,
|
|
171
|
+
command: candidate.command,
|
|
172
|
+
explicit: candidate.explicit,
|
|
173
|
+
tooOld: false
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return older
|
|
179
|
+
? { found: false, ...older, tooOld: true }
|
|
180
|
+
: { found: false, version: null, command: null, explicit: null, tooOld: false };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function emitPythonWarning(io, probe) {
|
|
184
|
+
if (!probe || probe.found) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (probe.tooOld) {
|
|
188
|
+
io.writeErr(
|
|
189
|
+
`Warning: Python ${probe.version ?? ''} (${probe.command}) is older than 3.10; `
|
|
190
|
+
+ '.cowork-flow/run needs Python 3.10+. Install a newer interpreter or set COWORK_FLOW_PYTHON.\n'
|
|
191
|
+
);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (probe.explicit) {
|
|
195
|
+
io.writeErr(
|
|
196
|
+
`Warning: ${probe.explicit} does not point to a usable Python 3.10+ interpreter; `
|
|
197
|
+
+ '.cowork-flow/run needs Python 3.10+.\n'
|
|
198
|
+
);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
io.writeErr(
|
|
202
|
+
'Warning: no usable Python 3.10+ interpreter found '
|
|
203
|
+
+ '(tried COWORK_FLOW_PYTHON, PYTHON, python3, python, py -3); '
|
|
204
|
+
+ '.cowork-flow/run needs Python 3.10+.\n'
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
112
208
|
async function readExistingDeveloper(target) {
|
|
113
209
|
const developerFile = join(target, '.cowork-flow', '.developer');
|
|
114
210
|
if (!await pathExists(developerFile)) {
|
|
@@ -292,13 +388,13 @@ async function buildDeveloperActions(target, developer) {
|
|
|
292
388
|
return actions;
|
|
293
389
|
}
|
|
294
390
|
|
|
295
|
-
export async function runInit(args, { io, prompt, selectPlatforms }) {
|
|
296
|
-
return runInitWithOptions(args, { io, prompt, selectPlatforms });
|
|
391
|
+
export async function runInit(args, { io, prompt, selectPlatforms, pythonProbe }) {
|
|
392
|
+
return runInitWithOptions(args, { io, prompt, selectPlatforms, pythonProbe });
|
|
297
393
|
}
|
|
298
394
|
|
|
299
395
|
export async function runInitWithOptions(
|
|
300
396
|
args,
|
|
301
|
-
{ io, prompt, selectPlatforms, fileSystem }
|
|
397
|
+
{ io, prompt, selectPlatforms, fileSystem, pythonProbe }
|
|
302
398
|
) {
|
|
303
399
|
const options = parseInitArgs(args);
|
|
304
400
|
const platforms = await resolvePlatforms(options, selectPlatforms);
|
|
@@ -325,6 +421,16 @@ export async function runInitWithOptions(
|
|
|
325
421
|
await applyPlan(plan, { dryRun: options.dryRun, fileSystem });
|
|
326
422
|
io.writeOut(summarizePlan(plan, options.dryRun));
|
|
327
423
|
io.writeOut(`Hosts: ${formatPlatformList(platforms)}\n`);
|
|
424
|
+
emitPythonWarning(io, await (pythonProbe ?? probePython)());
|
|
425
|
+
|
|
426
|
+
const emitNextSteps = () => {
|
|
427
|
+
io.writeOut(
|
|
428
|
+
`Next: open ${formatPlatformList(platforms)} in this project, start a new session, and describe what you want to build.\n`
|
|
429
|
+
);
|
|
430
|
+
io.writeOut(
|
|
431
|
+
'If the host needs machine-level setup, run: cwf host add <host> (see docs/hosts.md)\n'
|
|
432
|
+
);
|
|
433
|
+
};
|
|
328
434
|
|
|
329
435
|
if (options.dryRun) {
|
|
330
436
|
if (developer.existing) {
|
|
@@ -340,7 +446,7 @@ export async function runInitWithOptions(
|
|
|
340
446
|
} else {
|
|
341
447
|
io.writeOut(`dry-run would-create=.cowork-flow/config.yaml for language ${language.language}\n`);
|
|
342
448
|
}
|
|
343
|
-
|
|
449
|
+
emitNextSteps();
|
|
344
450
|
return 0;
|
|
345
451
|
}
|
|
346
452
|
|
|
@@ -357,6 +463,6 @@ export async function runInitWithOptions(
|
|
|
357
463
|
const source = language.source === 'default' ? ' (default)' : '';
|
|
358
464
|
io.writeOut(`Language initialized: ${language.language}${source}\n`);
|
|
359
465
|
}
|
|
360
|
-
|
|
466
|
+
emitNextSteps();
|
|
361
467
|
return 0;
|
|
362
468
|
}
|
|
@@ -15,8 +15,8 @@ const LOADS = ' Loads as cowork-flow@skills-dir in the next Claude Code session
|
|
|
15
15
|
export const FLAGS = ['--dry-run', '--force', '--uninstall'];
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
function claudeHome() {
|
|
19
|
-
const configured = (
|
|
18
|
+
function claudeHome(env = process.env) {
|
|
19
|
+
const configured = (env.CLAUDE_CONFIG_DIR || '').trim();
|
|
20
20
|
return configured || join(homedir(), '.claude');
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -88,3 +88,54 @@ export async function runInstallClaudeCodePlugin(args = []) {
|
|
|
88
88
|
onDone: () => console.log(LOADS)
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
// Read-only installed-state facts for `host inspect`.
|
|
94
|
+
export async function inspectInstalledState({ env = process.env } = {}) {
|
|
95
|
+
const target = installPath(claudeHome(env));
|
|
96
|
+
const { manifest } = pluginPayload('claude-code');
|
|
97
|
+
const installed = await readManifest(target, manifest);
|
|
98
|
+
if (!installed) {
|
|
99
|
+
return {
|
|
100
|
+
status: 'missing',
|
|
101
|
+
version: null,
|
|
102
|
+
payloadPath: target,
|
|
103
|
+
detailPath: target,
|
|
104
|
+
registeredSource: target,
|
|
105
|
+
enabled: null,
|
|
106
|
+
reason: 'no plugin manifest'
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (installed.name !== PLUGIN_NAME) {
|
|
110
|
+
return {
|
|
111
|
+
status: 'missing',
|
|
112
|
+
version: null,
|
|
113
|
+
payloadPath: target,
|
|
114
|
+
detailPath: target,
|
|
115
|
+
registeredSource: target,
|
|
116
|
+
enabled: null,
|
|
117
|
+
reason: 'a different plugin owns this directory'
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const skill = join(target, 'skills', 'cowork-flow-bootstrap', 'SKILL.md');
|
|
121
|
+
if (!(await pathExists(skill))) {
|
|
122
|
+
return {
|
|
123
|
+
status: 'broken',
|
|
124
|
+
version: typeof installed.version === 'string' ? installed.version : null,
|
|
125
|
+
payloadPath: target,
|
|
126
|
+
detailPath: skill,
|
|
127
|
+
registeredSource: target,
|
|
128
|
+
enabled: true,
|
|
129
|
+
reason: 'missing skills/cowork-flow-bootstrap/SKILL.md'
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
status: 'installed',
|
|
134
|
+
version: typeof installed.version === 'string' ? installed.version : null,
|
|
135
|
+
payloadPath: target,
|
|
136
|
+
detailPath: join(target, ...manifest.split('/')),
|
|
137
|
+
registeredSource: target,
|
|
138
|
+
enabled: true,
|
|
139
|
+
reason: null
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
|
-
import { cp, mkdir, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { delimiter, dirname, join, resolve } from 'node:path';
|
|
6
6
|
|
|
7
|
-
import { parseInstallArgs, pathExists } from '../lib/install-support.js';
|
|
7
|
+
import { parseInstallArgs, pathExists, readJsonFile } from '../lib/install-support.js';
|
|
8
8
|
import { readPackageInfo } from '../lib/package-info.js';
|
|
9
9
|
import { readPluginMetadata } from '../lib/plugin-metadata.js';
|
|
10
10
|
import { pluginPayload, stampPayloadManifest } from '../lib/plugin-payload.js';
|
|
@@ -19,11 +19,70 @@ const MARKETPLACE_MANIFEST = join('.agents', 'plugins', 'marketplace.json');
|
|
|
19
19
|
export const FLAGS = ['--dry-run', '--force', '--uninstall'];
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
function codexHome() {
|
|
23
|
-
const configured = (
|
|
22
|
+
function codexHome(env = process.env) {
|
|
23
|
+
const configured = (env.CODEX_HOME || '').trim();
|
|
24
24
|
return configured || join(homedir(), '.codex');
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
|
|
28
|
+
function stripTomlInlineComment(value) {
|
|
29
|
+
let quote = '';
|
|
30
|
+
let escaped = false;
|
|
31
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
32
|
+
const char = value[index];
|
|
33
|
+
if (escaped) {
|
|
34
|
+
escaped = false;
|
|
35
|
+
} else if (quote === '"' && char === '\\') {
|
|
36
|
+
escaped = true;
|
|
37
|
+
} else if (quote) {
|
|
38
|
+
if (char === quote) {
|
|
39
|
+
quote = '';
|
|
40
|
+
}
|
|
41
|
+
} else if (index === 0 && (char === '"' || char === "'")) {
|
|
42
|
+
quote = char;
|
|
43
|
+
} else if (char === '#' && (index === 0 || value[index - 1] === ' ' || value[index - 1] === '\t')) {
|
|
44
|
+
return value.slice(0, index).trimEnd();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
// The two flat sections cowork-flow owns in Codex's config.toml. Everything
|
|
52
|
+
// else in the file stays unread; this is registration state, not install layout.
|
|
53
|
+
async function readCodexConfig(home) {
|
|
54
|
+
const path = join(home, 'config.toml');
|
|
55
|
+
const sections = {};
|
|
56
|
+
let text;
|
|
57
|
+
try {
|
|
58
|
+
text = await readFile(path, 'utf8');
|
|
59
|
+
} catch {
|
|
60
|
+
return { path, sections };
|
|
61
|
+
}
|
|
62
|
+
let current = null;
|
|
63
|
+
for (const rawLine of text.split(/\r?\n/)) {
|
|
64
|
+
const line = rawLine.trim();
|
|
65
|
+
if (!line || line.startsWith('#')) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (line.startsWith('[') && line.endsWith(']')) {
|
|
69
|
+
const name = line.slice(1, -1).trim().replaceAll('"', '');
|
|
70
|
+
current = sections[name] = {};
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (!current || !line.includes('=')) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const index = line.indexOf('=');
|
|
77
|
+
const key = line.slice(0, index).trim().replace(/^["']|["']$/g, '');
|
|
78
|
+
const value = stripTomlInlineComment(line.slice(index + 1).trim())
|
|
79
|
+
.trim()
|
|
80
|
+
.replace(/^["']|["']$/g, '');
|
|
81
|
+
current[key] = value;
|
|
82
|
+
}
|
|
83
|
+
return { path, sections };
|
|
84
|
+
}
|
|
85
|
+
|
|
27
86
|
function marketplaceRoot(home) {
|
|
28
87
|
return join(home, 'plugins', 'marketplaces', MARKETPLACE_NAME);
|
|
29
88
|
}
|
|
@@ -310,3 +369,54 @@ export async function runInstallCodexPlugin(args = []) {
|
|
|
310
369
|
);
|
|
311
370
|
return 0;
|
|
312
371
|
}
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
// Read-only installed-state facts for `host inspect`.
|
|
375
|
+
export async function inspectInstalledState({ env = process.env } = {}) {
|
|
376
|
+
const home = codexHome(env);
|
|
377
|
+
const root = marketplaceRoot(home);
|
|
378
|
+
const config = await readCodexConfig(home);
|
|
379
|
+
const marketplace = config.sections[`marketplaces.${MARKETPLACE_NAME}`];
|
|
380
|
+
const plugin = config.sections[`plugins.${PLUGIN_KEY}`];
|
|
381
|
+
// A registered source is where the marketplace actually lives; fall back to
|
|
382
|
+
// the installer's own root only when the source is absent or unusable.
|
|
383
|
+
const registeredSource = marketplace?.source || root;
|
|
384
|
+
const payload = marketplace?.source
|
|
385
|
+
? join(marketplace.source, 'plugins', PLUGIN_NAME)
|
|
386
|
+
: pluginTarget(home);
|
|
387
|
+
const { manifest } = pluginPayload('codex');
|
|
388
|
+
const payloadManifest = await readJsonFile(join(payload, ...manifest.split('/')));
|
|
389
|
+
if (!marketplace) {
|
|
390
|
+
return {
|
|
391
|
+
status: 'missing',
|
|
392
|
+
version: null,
|
|
393
|
+
payloadPath: payloadManifest ? payload : null,
|
|
394
|
+
detailPath: config.path,
|
|
395
|
+
registeredSource: config.path,
|
|
396
|
+
enabled: null,
|
|
397
|
+
reason: 'marketplace is not registered'
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
if (!payloadManifest) {
|
|
401
|
+
return {
|
|
402
|
+
status: 'broken',
|
|
403
|
+
version: null,
|
|
404
|
+
payloadPath: payload,
|
|
405
|
+
detailPath: join(payload, ...manifest.split('/')),
|
|
406
|
+
registeredSource,
|
|
407
|
+
enabled: plugin?.enabled === 'true',
|
|
408
|
+
reason: `missing ${manifest}`
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
return {
|
|
412
|
+
status: 'installed',
|
|
413
|
+
version: typeof payloadManifest.version === 'string' ? payloadManifest.version : null,
|
|
414
|
+
payloadPath: payload,
|
|
415
|
+
detailPath: plugin?.enabled === 'true'
|
|
416
|
+
? join(payload, ...manifest.split('/'))
|
|
417
|
+
: config.path,
|
|
418
|
+
registeredSource,
|
|
419
|
+
enabled: plugin?.enabled === 'true',
|
|
420
|
+
reason: null
|
|
421
|
+
};
|
|
422
|
+
}
|
|
@@ -205,3 +205,54 @@ export async function runInstallDshHook(args = []) {
|
|
|
205
205
|
console.log(' Keep only one to avoid duplicate injection: remove the preset, or run "cwf host remove dsh --component hook".');
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
// Read-only installed-state facts for `host inspect`.
|
|
211
|
+
export async function inspectInstalledState({ env = process.env } = {}) {
|
|
212
|
+
const home = getDshHome(env);
|
|
213
|
+
const pluginDest = join(home, 'plugins', 'cowork-flow', 'workflow-state.js');
|
|
214
|
+
const patchFile = join(home, 'cordis.patch.yml');
|
|
215
|
+
const patch = await readIfExists(patchFile);
|
|
216
|
+
if (patch === null) {
|
|
217
|
+
return {
|
|
218
|
+
status: 'missing',
|
|
219
|
+
version: null,
|
|
220
|
+
payloadPath: pluginDest,
|
|
221
|
+
detailPath: patchFile,
|
|
222
|
+
registeredSource: patchFile,
|
|
223
|
+
enabled: null,
|
|
224
|
+
reason: 'no patch file'
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
if (!patch.includes(`- id: ${ROW_ID}`)) {
|
|
228
|
+
return {
|
|
229
|
+
status: 'missing',
|
|
230
|
+
version: null,
|
|
231
|
+
payloadPath: pluginDest,
|
|
232
|
+
detailPath: patchFile,
|
|
233
|
+
registeredSource: patchFile,
|
|
234
|
+
enabled: null,
|
|
235
|
+
reason: 'no managed hook row'
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (!(await pathExists(pluginDest))) {
|
|
239
|
+
return {
|
|
240
|
+
status: 'broken',
|
|
241
|
+
version: null,
|
|
242
|
+
payloadPath: pluginDest,
|
|
243
|
+
detailPath: pluginDest,
|
|
244
|
+
registeredSource: patchFile,
|
|
245
|
+
enabled: true,
|
|
246
|
+
reason: 'plugin file is missing'
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
status: 'installed',
|
|
251
|
+
version: null,
|
|
252
|
+
payloadPath: pluginDest,
|
|
253
|
+
detailPath: pluginDest,
|
|
254
|
+
registeredSource: patchFile,
|
|
255
|
+
enabled: true,
|
|
256
|
+
reason: null
|
|
257
|
+
};
|
|
258
|
+
}
|
|
@@ -25,22 +25,26 @@ const DESKTOP_ROW_SWAP = {
|
|
|
25
25
|
from: { id: 'workflow-worker-thread', name: '@deepseek-ai/dsh-workflow-worker-thread' },
|
|
26
26
|
to: { id: 'workflow-ptc', name: '@deepseek-ai/dsh-workflow-ptc' },
|
|
27
27
|
};
|
|
28
|
-
// 0.2.0's `dsh-persona` takes `prefix`/`suffix` where 0.1.x takes one `text
|
|
29
|
-
//
|
|
28
|
+
// 0.2.0's `dsh-persona` takes `prefix`/`suffix` where 0.1.x takes one `text`.
|
|
29
|
+
// Its persona section resolves only `provider`/`model` — the working directory
|
|
30
|
+
// arrives as user-role context from `dsh-working-directory` — so the 0.1.x
|
|
31
|
+
// `{{cwd}}` clause is dropped; 0.1.x resolves that variable from the agent's
|
|
32
|
+
// workspace.
|
|
30
33
|
const DESKTOP_PERSONA_KEY = /(- id: persona\n(?:.*\n)*? {4})text: /;
|
|
34
|
+
const DESKTOP_CWD_CLAUSE = ' Your working directory is {{cwd}}.';
|
|
31
35
|
|
|
32
36
|
// Rendered by `host add`/`host remove`; the installer's
|
|
33
37
|
// own vocabulary.
|
|
34
38
|
export const FLAGS = ['--dry-run', '--force', '--uninstall'];
|
|
35
39
|
|
|
36
40
|
|
|
37
|
-
function getDshPresetRoot() {
|
|
38
|
-
return join(getDshHome(), '.agent-presets');
|
|
41
|
+
function getDshPresetRoot(env = process.env) {
|
|
42
|
+
return join(getDshHome(env), '.agent-presets');
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
|
|
42
|
-
function getBundleRoot() {
|
|
43
|
-
return join(getDshHome(), 'bundles');
|
|
46
|
+
function getBundleRoot(env = process.env) {
|
|
47
|
+
return join(getDshHome(env), 'bundles');
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
|
|
@@ -85,8 +89,8 @@ function quoteScalar(value) {
|
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
|
|
88
|
-
// Apply the desktop's
|
|
89
|
-
//
|
|
92
|
+
// Apply the desktop's rewrites to the 0.1.x composition. Only what the host
|
|
93
|
+
// APIs force to differ between the two lines belongs here.
|
|
90
94
|
function toDesktopComposition(text) {
|
|
91
95
|
return text
|
|
92
96
|
.replace(`- id: ${DESKTOP_ROW_SWAP.from.id}`, `- id: ${DESKTOP_ROW_SWAP.to.id}`)
|
|
@@ -94,7 +98,8 @@ function toDesktopComposition(text) {
|
|
|
94
98
|
`name: '${DESKTOP_ROW_SWAP.from.name}'`,
|
|
95
99
|
`name: '${DESKTOP_ROW_SWAP.to.name}'`
|
|
96
100
|
)
|
|
97
|
-
.replace(DESKTOP_PERSONA_KEY, '$1prefix: ')
|
|
101
|
+
.replace(DESKTOP_PERSONA_KEY, '$1prefix: ')
|
|
102
|
+
.replace(DESKTOP_CWD_CLAUSE, '');
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
|
|
@@ -277,3 +282,45 @@ export async function runInstallDshPreset(args = []) {
|
|
|
277
282
|
console.log(' desktop - the Plugins page in the sidebar, entering that absolute path');
|
|
278
283
|
console.log(' Then start a new session; running sessions keep the plugins they started with.');
|
|
279
284
|
}
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
// Read-only installed-state facts for `host inspect`.
|
|
288
|
+
export async function inspectInstalledState({ env = process.env } = {}) {
|
|
289
|
+
const presetDir = join(getDshPresetRoot(env), PRESET_ID);
|
|
290
|
+
const bundleDir = join(getBundleRoot(env), PRESET_ID);
|
|
291
|
+
const legacyPresent = await pathExists(presetDir);
|
|
292
|
+
const bundlePresent = await pathExists(bundleDir);
|
|
293
|
+
if (!legacyPresent && !bundlePresent) {
|
|
294
|
+
return {
|
|
295
|
+
status: 'missing',
|
|
296
|
+
version: null,
|
|
297
|
+
payloadPath: null,
|
|
298
|
+
detailPath: null,
|
|
299
|
+
registeredSource: null,
|
|
300
|
+
enabled: null,
|
|
301
|
+
reason: 'no preset directory or bundle'
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const payloadPath = legacyPresent ? presetDir : bundleDir;
|
|
305
|
+
const version = await readInstalledVersion(payloadPath);
|
|
306
|
+
if (version === null) {
|
|
307
|
+
return {
|
|
308
|
+
status: 'broken',
|
|
309
|
+
version: null,
|
|
310
|
+
payloadPath,
|
|
311
|
+
detailPath: join(payloadPath, MARKER_FILE),
|
|
312
|
+
registeredSource: payloadPath,
|
|
313
|
+
enabled: null,
|
|
314
|
+
reason: 'version marker is missing or unreadable'
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
status: 'installed',
|
|
319
|
+
version,
|
|
320
|
+
payloadPath,
|
|
321
|
+
detailPath: join(payloadPath, MARKER_FILE),
|
|
322
|
+
registeredSource: payloadPath,
|
|
323
|
+
enabled: null,
|
|
324
|
+
reason: null
|
|
325
|
+
};
|
|
326
|
+
}
|