@principles/workbuddy-adapter 0.0.0-stage → 0.2.1
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 +73 -0
- package/NOTICE +2 -0
- package/dist/codec/index.d.ts +2 -0
- package/dist/codec/index.js +2 -0
- package/dist/codec/input-decoder.d.ts +30 -0
- package/dist/codec/input-decoder.js +232 -0
- package/dist/codec/output-encoder.d.ts +62 -0
- package/dist/codec/output-encoder.js +75 -0
- package/dist/host-adapter.d.ts +33 -0
- package/dist/host-adapter.js +23 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +16 -0
- package/dist/pd-hook.d.ts +17 -0
- package/dist/pd-hook.js +505 -0
- package/dist/tool-semantics.d.ts +22 -0
- package/dist/tool-semantics.js +33 -0
- package/dist/workbuddy-evidence-recorder.d.ts +50 -0
- package/dist/workbuddy-evidence-recorder.js +238 -0
- package/dist/worker/workspace-worker.d.ts +41 -0
- package/dist/worker/workspace-worker.js +219 -0
- package/dist/workspace-resolution.d.ts +15 -0
- package/dist/workspace-resolution.js +53 -0
- package/package.json +62 -4
- package/plugin/.codebuddy-plugin/plugin.json +6 -0
- package/plugin/hooks/hooks.json +62 -0
- package/plugin/scripts/wrapper.cjs +79 -0
- package/README.md +0 -3
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"PreToolUse": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "*",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"${CODEBUDDY_PLUGIN_ROOT}/scripts/wrapper.cjs\" PreToolUse",
|
|
10
|
+
"timeout": 30
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"PostToolUse": [
|
|
16
|
+
{
|
|
17
|
+
"matcher": "*",
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "node \"${CODEBUDDY_PLUGIN_ROOT}/scripts/wrapper.cjs\" PostToolUse",
|
|
22
|
+
"timeout": 30
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"PostToolUseFailure": [
|
|
28
|
+
{
|
|
29
|
+
"matcher": "*",
|
|
30
|
+
"hooks": [
|
|
31
|
+
{
|
|
32
|
+
"type": "command",
|
|
33
|
+
"command": "node \"${CODEBUDDY_PLUGIN_ROOT}/scripts/wrapper.cjs\" PostToolUseFailure",
|
|
34
|
+
"timeout": 30
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"UserPromptSubmit": [
|
|
40
|
+
{
|
|
41
|
+
"hooks": [
|
|
42
|
+
{
|
|
43
|
+
"type": "command",
|
|
44
|
+
"command": "node \"${CODEBUDDY_PLUGIN_ROOT}/scripts/wrapper.cjs\" UserPromptSubmit",
|
|
45
|
+
"timeout": 30
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"SessionStart": [
|
|
51
|
+
{
|
|
52
|
+
"hooks": [
|
|
53
|
+
{
|
|
54
|
+
"type": "command",
|
|
55
|
+
"command": "node \"${CODEBUDDY_PLUGIN_ROOT}/scripts/wrapper.cjs\" SessionStart",
|
|
56
|
+
"timeout": 30
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/**
|
|
4
|
+
* PD WorkBuddy plugin hook wrapper.
|
|
5
|
+
*
|
|
6
|
+
* WorkBuddy executes plugin hook commands via Git Bash (probe P05, verified
|
|
7
|
+
* with spaces AND Chinese characters in both the plugin root and the project
|
|
8
|
+
* cwd). This wrapper is deliberately DUMB TRANSPORT: forward stdin, stdout,
|
|
9
|
+
* stderr and the exit code to the real adapter entry, nothing else. All
|
|
10
|
+
* governance decisions (including WHICH failures may block via exit 2) live
|
|
11
|
+
* in the adapter entry — never here.
|
|
12
|
+
*
|
|
13
|
+
* Entry resolution order:
|
|
14
|
+
* 1. PD_WORKBUDDY_ADAPTER_ENTRY (absolute path) — development and test
|
|
15
|
+
* override;
|
|
16
|
+
* 2. the installer-managed canonical runtime adapter dir, matching
|
|
17
|
+
* @principles/install-layout getInstallLayoutPaths(homeDir)
|
|
18
|
+
* .workbuddyAdapterDir (= <home>/.pd/runtime/workbuddy-adapter) with the
|
|
19
|
+
* built entry at dist/pd-hook.js. The literal path here is LOCKED to the
|
|
20
|
+
* install-layout SSoT by tests/plugin-skeleton.test.ts.
|
|
21
|
+
*
|
|
22
|
+
* On a wrapper-level failure (entry missing / spawn failure) the wrapper exits
|
|
23
|
+
* 1 with a bounded stderr diagnostic: probe P02 established exit 1 is
|
|
24
|
+
* non-blocking on WorkBuddy, and the SPEC §4.4 startup-failure row forbids
|
|
25
|
+
* claiming self-blocking the wrapper cannot guarantee.
|
|
26
|
+
*/
|
|
27
|
+
const { spawnSync } = require('node:child_process');
|
|
28
|
+
const fs = require('node:fs');
|
|
29
|
+
const path = require('node:path');
|
|
30
|
+
|
|
31
|
+
const eventName = process.argv[2];
|
|
32
|
+
|
|
33
|
+
function fail(message) {
|
|
34
|
+
try {
|
|
35
|
+
process.stderr.write(`[PD] status=degraded reason=workbuddy_wrapper:${message} nextAction=Reinstall PD (npx create-principles-disciple) or set PD_WORKBUDDY_ADAPTER_ENTRY to the built adapter entry.\n`);
|
|
36
|
+
} catch (_) { /* no channel left */ }
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function resolveEntry() {
|
|
41
|
+
const override = process.env.PD_WORKBUDDY_ADAPTER_ENTRY;
|
|
42
|
+
if (override && override.trim().length > 0) {
|
|
43
|
+
return override.trim();
|
|
44
|
+
}
|
|
45
|
+
const homeDir = process.env.USERPROFILE || process.env.HOME;
|
|
46
|
+
if (!homeDir) fail('no_home_dir');
|
|
47
|
+
// Mirrors @principles/install-layout getInstallLayoutPaths().workbuddyAdapterDir.
|
|
48
|
+
const adapterDir = path.join(homeDir, '.pd', 'runtime', 'workbuddy-adapter');
|
|
49
|
+
return path.join(adapterDir, 'dist', 'pd-hook.js');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!eventName || eventName.trim().length === 0) {
|
|
53
|
+
fail('missing_event_argument');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const entry = resolveEntry();
|
|
57
|
+
// Pre-check existence: spawning a missing script surfaces as node's own
|
|
58
|
+
// MODULE_NOT_FOUND (exit 1, unstructured) — the wrapper owns a BOUNDED,
|
|
59
|
+
// actionable diagnostic instead (P02 startup-failure boundary).
|
|
60
|
+
try {
|
|
61
|
+
if (!fs.statSync(entry).isFile()) fail('entry_not_found: not a regular file');
|
|
62
|
+
} catch (_) {
|
|
63
|
+
fail('entry_not_found:' + entry.slice(0, 120));
|
|
64
|
+
}
|
|
65
|
+
const child = spawnSync(process.execPath, [entry, eventName], {
|
|
66
|
+
stdio: ['inherit', 'inherit', 'inherit'],
|
|
67
|
+
windowsHide: true,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (child.error) {
|
|
71
|
+
const code = child.error.code === 'ENOENT' ? 'entry_not_found' : 'spawn_failed';
|
|
72
|
+
fail(`${code}:${child.error.message.slice(0, 120)}`);
|
|
73
|
+
}
|
|
74
|
+
if (child.status === null) {
|
|
75
|
+
// Killed by signal (e.g. host timeout): mirror as a non-blocking exit 1
|
|
76
|
+
// with the observable reason; P02 timeout semantics are host-managed.
|
|
77
|
+
fail(`entry_killed_signal:${String(child.signal).slice(0, 30)}`);
|
|
78
|
+
}
|
|
79
|
+
process.exit(child.status);
|
package/README.md
DELETED