@useorgx/orgx-opencode-plugin 0.1.0-alpha.1 → 0.1.0-alpha.11
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 +126 -3
- package/dist/OpenCodeDriver.d.ts +5 -2
- package/dist/OpenCodeDriver.d.ts.map +1 -1
- package/dist/OpenCodeDriver.js +12 -1
- package/dist/OpenCodeDriver.js.map +1 -1
- package/dist/attentionBridge.d.ts +38 -0
- package/dist/attentionBridge.d.ts.map +1 -0
- package/dist/attentionBridge.js +230 -0
- package/dist/attentionBridge.js.map +1 -0
- package/dist/childProcessEnv.d.ts +5 -0
- package/dist/childProcessEnv.d.ts.map +1 -0
- package/dist/childProcessEnv.js +17 -0
- package/dist/childProcessEnv.js.map +1 -0
- package/dist/cli.js +6 -3
- package/dist/cli.js.map +1 -1
- package/dist/contextPackHydration.d.ts +14 -0
- package/dist/contextPackHydration.d.ts.map +1 -0
- package/dist/contextPackHydration.js +57 -0
- package/dist/contextPackHydration.js.map +1 -0
- package/dist/continuityHealth.d.ts +48 -0
- package/dist/continuityHealth.d.ts.map +1 -0
- package/dist/continuityHealth.js +118 -0
- package/dist/continuityHealth.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/peer.d.ts +14 -0
- package/dist/peer.d.ts.map +1 -1
- package/dist/peer.js +142 -13
- package/dist/peer.js.map +1 -1
- package/dist/plugin.d.ts +17 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +124 -0
- package/dist/plugin.js.map +1 -0
- package/dist/sentry.d.ts +4 -0
- package/dist/sentry.d.ts.map +1 -0
- package/dist/sentry.js +97 -0
- package/dist/sentry.js.map +1 -0
- package/dist/sessionSummaryBridge.d.ts +20 -0
- package/dist/sessionSummaryBridge.d.ts.map +1 -0
- package/dist/sessionSummaryBridge.js +125 -0
- package/dist/sessionSummaryBridge.js.map +1 -0
- package/dist/v2Canary.d.ts +13 -0
- package/dist/v2Canary.d.ts.map +1 -0
- package/dist/v2Canary.js +27 -0
- package/dist/v2Canary.js.map +1 -0
- package/dist/workGraphOutbox.js +2 -2
- package/dist/workGraphOutbox.js.map +1 -1
- package/dist/workGraphReplay.d.ts +9 -0
- package/dist/workGraphReplay.d.ts.map +1 -0
- package/dist/workGraphReplay.js +41 -0
- package/dist/workGraphReplay.js.map +1 -0
- package/package.json +30 -9
- package/plugin.manifest.json +8 -2
- package/scripts/orgx-work-graph-reconcile.mjs +994 -0
- package/scripts/orgx-work-graph-reconcile.node-test.mjs +131 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdtempSync, readFileSync, symlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import test from 'node:test';
|
|
6
|
+
import { pathToFileURL } from 'node:url';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
buildWorkGraphReport,
|
|
10
|
+
isDirectRun,
|
|
11
|
+
loadHookOutboxRecords,
|
|
12
|
+
main,
|
|
13
|
+
normalizeSourceClient,
|
|
14
|
+
parseArgs,
|
|
15
|
+
postWorkGraphReport,
|
|
16
|
+
} from './orgx-work-graph-reconcile.mjs';
|
|
17
|
+
|
|
18
|
+
const NOW = '2026-05-07T12:00:00.000Z';
|
|
19
|
+
|
|
20
|
+
function hookRecord(overrides = {}) {
|
|
21
|
+
return {
|
|
22
|
+
schema_version: '2026-05-07',
|
|
23
|
+
source: 'orgx_opencode_plugin_runtime_hook',
|
|
24
|
+
source_client: 'opencode',
|
|
25
|
+
event: 'task_step',
|
|
26
|
+
run_id: 'run-1',
|
|
27
|
+
session_id: 'session-1',
|
|
28
|
+
cwd: '/Users/example/Code/orgx',
|
|
29
|
+
timestamp: NOW,
|
|
30
|
+
summary: {
|
|
31
|
+
tool_name: 'mcp__orgx__entity_action',
|
|
32
|
+
prompt_chars: 42,
|
|
33
|
+
payload_keys: ['tool_name', 'cwd'],
|
|
34
|
+
},
|
|
35
|
+
...overrides,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
test('work graph reconciler normalizes shared client names', () => {
|
|
40
|
+
assert.equal(normalizeSourceClient('claude_code'), 'claude-code');
|
|
41
|
+
assert.equal(normalizeSourceClient('open-claw'), 'openclaw');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('work graph reconciler posts reports privately with server dedupe', async () => {
|
|
45
|
+
let requestBody;
|
|
46
|
+
await postWorkGraphReport({
|
|
47
|
+
report: { idempotency_key: 'stable-fingerprint' },
|
|
48
|
+
baseUrl: 'https://example.org',
|
|
49
|
+
apiKey: 'oxk_test_only',
|
|
50
|
+
fetchImpl: async (_url, init) => {
|
|
51
|
+
requestBody = JSON.parse(init.body);
|
|
52
|
+
return new Response(JSON.stringify({ ok: true }), {
|
|
53
|
+
status: 200,
|
|
54
|
+
headers: { 'content-type': 'application/json' },
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
assert.equal(requestBody.public_share, false);
|
|
60
|
+
assert.equal(requestBody.report.idempotency_key, 'stable-fingerprint');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('work graph reconciler parses split CLI values', () => {
|
|
64
|
+
const args = parseArgs(['--outbox', '/tmp/events.jsonl', '--post']);
|
|
65
|
+
assert.equal(args.outbox, '/tmp/events.jsonl');
|
|
66
|
+
assert.equal(args.post, 'true');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('work graph reconciler direct-run check resolves npm bin symlinks', () => {
|
|
70
|
+
const dir = mkdtempSync(join(tmpdir(), 'orgx-opencode-bin-'));
|
|
71
|
+
const target = join(dir, 'orgx-work-graph-reconcile.mjs');
|
|
72
|
+
const bin = join(dir, 'orgx-opencode-reconcile-hooks');
|
|
73
|
+
writeFileSync(target, '#!/usr/bin/env node\n', 'utf8');
|
|
74
|
+
symlinkSync(target, bin);
|
|
75
|
+
|
|
76
|
+
assert.equal(
|
|
77
|
+
isDirectRun({ invokedPath: bin, moduleUrl: pathToFileURL(target).href }),
|
|
78
|
+
true
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('work graph reconciler reads OpenCode hook outbox jsonl', async () => {
|
|
83
|
+
const outbox = join(mkdtempSync(join(tmpdir(), 'orgx-opencode-reconcile-')), 'events.jsonl');
|
|
84
|
+
writeFileSync(outbox, `${JSON.stringify(hookRecord())}\nnot json\n`, 'utf8');
|
|
85
|
+
|
|
86
|
+
const loaded = await loadHookOutboxRecords(outbox);
|
|
87
|
+
assert.equal(loaded.records.length, 1);
|
|
88
|
+
assert.equal(loaded.skipped, 1);
|
|
89
|
+
assert.equal(loaded.records[0].source_client, 'opencode');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('work graph reconciler emits OrgX-compatible summary-only report', () => {
|
|
93
|
+
const report = buildWorkGraphReport([hookRecord()], {
|
|
94
|
+
generatedAt: NOW,
|
|
95
|
+
workspaceCwd: '/Users/example/Code/orgx',
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
assert.match(report.work_graph_fingerprint, /^wgf_[0-9a-f]{24}$/);
|
|
99
|
+
assert.equal(
|
|
100
|
+
report.signup_hydration.hydration_key,
|
|
101
|
+
`orgx:work-graph:${report.work_graph_fingerprint}`
|
|
102
|
+
);
|
|
103
|
+
assert.equal(report.source_client, 'wizard');
|
|
104
|
+
assert.equal(report.raw_transcripts_sent, false);
|
|
105
|
+
assert.equal(report.investigation.raw_transcripts_excluded, true);
|
|
106
|
+
assert.equal(report.investigation.fingerprint, report.work_graph_fingerprint);
|
|
107
|
+
assert.equal(report.investigation.generated_at, NOW);
|
|
108
|
+
assert.equal(typeof report.investigation.why_not_100[0], 'object');
|
|
109
|
+
assert.equal(report.events[0].event_type, 'tool_signal');
|
|
110
|
+
assert.equal(report.source_coverage.orgxMcpCalled, true);
|
|
111
|
+
assert.deepEqual(report.missed_orchestration_opportunities, []);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('work graph reconciler dry-run writes report without credentials', async () => {
|
|
115
|
+
const dir = mkdtempSync(join(tmpdir(), 'orgx-opencode-reconcile-main-'));
|
|
116
|
+
const outbox = join(dir, 'events.jsonl');
|
|
117
|
+
const output = join(dir, 'report.json');
|
|
118
|
+
writeFileSync(outbox, `${JSON.stringify(hookRecord())}\n`, 'utf8');
|
|
119
|
+
|
|
120
|
+
const result = await main({
|
|
121
|
+
argv: [`--outbox=${outbox}`, `--output=${output}`, '--cwd=/repo'],
|
|
122
|
+
env: {},
|
|
123
|
+
now: () => new Date(NOW),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
assert.equal(result.ok, true);
|
|
127
|
+
assert.equal(result.records_read, 1);
|
|
128
|
+
const written = JSON.parse(readFileSync(output, 'utf8'));
|
|
129
|
+
assert.equal(written.work_graph_fingerprint, result.work_graph_fingerprint);
|
|
130
|
+
assert.equal(written.report.raw_transcripts_sent, false);
|
|
131
|
+
});
|