@agfpd/iapeer 0.2.28 → 0.2.29
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/package.json +1 -1
- package/src/cli/cli.test.ts +54 -0
- package/src/cli/index.ts +7 -1
package/package.json
CHANGED
package/src/cli/cli.test.ts
CHANGED
|
@@ -40,6 +40,60 @@ async function register(personality: string, runtime = 'claude', intelligence: '
|
|
|
40
40
|
await upsertPeer({ personality, runtime, cwd: `/tmp/${personality}`, intelligence }, { rootDir: root })
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// ─── v1.2 provision-инверсия at the CLI joints (memory-plugin printer + remove) ───
|
|
44
|
+
|
|
45
|
+
describe('memory-plugin / remove with a v1.2 provision slot', () => {
|
|
46
|
+
function declareV12Slot(): string {
|
|
47
|
+
const journal = join(root, 'journal.txt')
|
|
48
|
+
const script = join(root, 'fake-provider.sh')
|
|
49
|
+
writeFileSync(script, `#!/bin/sh\nprintf '%s\\n' "$@" >> '${journal}'\n`, { mode: 0o755 })
|
|
50
|
+
writeFileSync(
|
|
51
|
+
join(root, 'memory-provider.json'),
|
|
52
|
+
JSON.stringify({
|
|
53
|
+
provider: 'fake-mem',
|
|
54
|
+
package: '@x/fake',
|
|
55
|
+
version: '0.0.1',
|
|
56
|
+
registeredAt: 'x',
|
|
57
|
+
provision: { command: script, args: ['provision-peer', '--occasion', '{occasion}'] },
|
|
58
|
+
unprovision: { command: script, args: ['unprovision-peer', '--cwd', '{cwd}', '--occasion', '{occasion}'] },
|
|
59
|
+
}),
|
|
60
|
+
)
|
|
61
|
+
return journal
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
test('memory-plugin on --peer: printer survives plugin=null (v1.2 path), exit 0 (live-caught 11.06 smoke)', async () => {
|
|
65
|
+
declareV12Slot()
|
|
66
|
+
await register('alpha')
|
|
67
|
+
let captured = ''
|
|
68
|
+
const origWrite = process.stdout.write
|
|
69
|
+
process.stdout.write = ((s: string | Uint8Array) => {
|
|
70
|
+
captured += typeof s === 'string' ? s : Buffer.from(s).toString('utf8')
|
|
71
|
+
return true
|
|
72
|
+
}) as typeof process.stdout.write
|
|
73
|
+
try {
|
|
74
|
+
const code = await runCli(['memory-plugin', 'on', '--peer', 'alpha'], env())
|
|
75
|
+
expect(code).toBe(0)
|
|
76
|
+
expect(captured).toContain('provision: provider command')
|
|
77
|
+
expect(captured).toContain('alpha (claude): ok')
|
|
78
|
+
} finally {
|
|
79
|
+
process.stdout.write = origWrite
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test('remove: unprovision runs with occasion=remove BEFORE the purge, outcome reported', async () => {
|
|
84
|
+
const journal = declareV12Slot()
|
|
85
|
+
await register('beta')
|
|
86
|
+
const o = await removePeerCli('beta', { env: env() })
|
|
87
|
+
expect(o.action).toBe('removed')
|
|
88
|
+
expect(o.unprovision).toEqual(['claude:ok'])
|
|
89
|
+
const { readFileSync } = await import('fs')
|
|
90
|
+
const j = readFileSync(journal, 'utf8')
|
|
91
|
+
expect(j).toContain('unprovision-peer')
|
|
92
|
+
expect(j).toContain('--cwd\n/tmp/beta')
|
|
93
|
+
expect(j).toContain('remove')
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
|
|
43
97
|
describe('list', () => {
|
|
44
98
|
test('lists registered peers with per-runtime liveness (asleep / stopped)', async () => {
|
|
45
99
|
await register('alpha')
|
package/src/cli/index.ts
CHANGED
|
@@ -668,7 +668,13 @@ export async function runCli(argv: string[], env: NodeJS.ProcessEnv = process.en
|
|
|
668
668
|
errOut(`memory-plugin: ${r.error}\n`)
|
|
669
669
|
return 1
|
|
670
670
|
}
|
|
671
|
-
|
|
671
|
+
// v1.2: a provision-declaring slot routes through the provider's commands —
|
|
672
|
+
// r.plugin is null then (there is no marketplace plugin in play to print).
|
|
673
|
+
out(
|
|
674
|
+
r.plugin
|
|
675
|
+
? `plugin: ${r.plugin.name}@${r.plugin.marketplace} (provider-declared)\n`
|
|
676
|
+
: `provision: provider command (declaration v1.2, occasion=${state === 'on' ? 'sweep-on' : flags.all === true ? 'off-all' : 'off-peer'})\n`,
|
|
677
|
+
)
|
|
672
678
|
for (const o of r.outcomes) {
|
|
673
679
|
out(`${o.personality} (${o.runtime}): ${o.state}${o.detail ? ` — ${o.detail}` : ''}\n`)
|
|
674
680
|
}
|