@celljs/ta-harness 4.6.1 → 4.8.0
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/README.en.md +15 -0
- package/README.md +2 -2
- package/esm/node/brand-extension.js +1 -1
- package/esm/node/brand-extension.js.map +1 -1
- package/esm/node/bug-report.d.ts +2 -0
- package/esm/node/bug-report.js +7 -0
- package/esm/node/bug-report.js.map +1 -1
- package/esm/node/exec-extension.d.ts +4 -2
- package/esm/node/exec-extension.js +10 -3
- package/esm/node/exec-extension.js.map +1 -1
- package/esm/node/exec-operations.d.ts +9 -2
- package/esm/node/exec-operations.js +26 -12
- package/esm/node/exec-operations.js.map +1 -1
- package/esm/node/index.d.ts +1 -0
- package/esm/node/index.js +1 -0
- package/esm/node/index.js.map +1 -1
- package/esm/node/remote-context-files.d.ts +17 -0
- package/esm/node/remote-context-files.js +43 -0
- package/esm/node/remote-context-files.js.map +1 -0
- package/esm/node/ta-packages.js +9 -1
- package/esm/node/ta-packages.js.map +1 -1
- package/lib/node/brand-extension.d.ts.map +1 -1
- package/lib/node/brand-extension.js +1 -1
- package/lib/node/brand-extension.js.map +1 -1
- package/lib/node/bug-report.d.ts +2 -0
- package/lib/node/bug-report.d.ts.map +1 -1
- package/lib/node/bug-report.js +7 -0
- package/lib/node/bug-report.js.map +1 -1
- package/lib/node/bug-report.spec.d.ts +2 -0
- package/lib/node/bug-report.spec.d.ts.map +1 -0
- package/lib/node/bug-report.spec.js +11 -0
- package/lib/node/bug-report.spec.js.map +1 -0
- package/lib/node/exec-extension.d.ts +4 -2
- package/lib/node/exec-extension.d.ts.map +1 -1
- package/lib/node/exec-extension.js +10 -3
- package/lib/node/exec-extension.js.map +1 -1
- package/lib/node/exec-operations.d.ts +9 -2
- package/lib/node/exec-operations.d.ts.map +1 -1
- package/lib/node/exec-operations.js +25 -11
- package/lib/node/exec-operations.js.map +1 -1
- package/lib/node/exec-operations.spec.js +2 -1
- package/lib/node/exec-operations.spec.js.map +1 -1
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/remote-context-files.d.ts +18 -0
- package/lib/node/remote-context-files.d.ts.map +1 -0
- package/lib/node/remote-context-files.js +46 -0
- package/lib/node/remote-context-files.js.map +1 -0
- package/lib/node/remote-context-files.spec.d.ts +2 -0
- package/lib/node/remote-context-files.spec.d.ts.map +1 -0
- package/lib/node/remote-context-files.spec.js +37 -0
- package/lib/node/remote-context-files.spec.js.map +1 -0
- package/lib/node/ta-packages.d.ts.map +1 -1
- package/lib/node/ta-packages.js +9 -1
- package/lib/node/ta-packages.js.map +1 -1
- package/package.json +4 -4
- package/src/node/brand-extension.ts +1 -4
- package/src/node/bug-report.spec.ts +9 -0
- package/src/node/bug-report.ts +7 -0
- package/src/node/exec-extension.ts +9 -2
- package/src/node/exec-operations.spec.ts +2 -1
- package/src/node/exec-operations.ts +29 -12
- package/src/node/index.ts +1 -0
- package/src/node/remote-context-files.spec.ts +37 -0
- package/src/node/remote-context-files.ts +51 -0
- package/src/node/ta-packages.ts +9 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { mkdirSync, mkdtempSync, realpathSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { LocalExecEnvironment } from '@celljs/ta-exec';
|
|
6
|
+
import { ExecOperations } from './exec-operations';
|
|
7
|
+
import { RemoteContextFiles } from './remote-context-files';
|
|
8
|
+
|
|
9
|
+
describe('RemoteContextFiles', () => {
|
|
10
|
+
it('lists the directory and those above it, the outermost first', () => {
|
|
11
|
+
expect(RemoteContextFiles.directories('/srv/app/')).toEqual(['/', '/srv', '/srv/app']);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('reads one file per directory, by pi names in pi order', async () => {
|
|
15
|
+
const root = realpathSync(mkdtempSync(join(tmpdir(), 'ta-context-')));
|
|
16
|
+
const app = join(root, 'app');
|
|
17
|
+
mkdirSync(join(app, 'CLAUDE.md'), { recursive: true });
|
|
18
|
+
writeFileSync(join(root, 'AGENTS.md'), '\uFEFFroot');
|
|
19
|
+
writeFileSync(join(root, 'CLAUDE.md'), 'not this');
|
|
20
|
+
writeFileSync(join(app, 'AGENTS.override.md'), 'app');
|
|
21
|
+
const files = await RemoteContextFiles.load(new LocalExecEnvironment(app));
|
|
22
|
+
expect(files.slice(-2)).toEqual([
|
|
23
|
+
{ path: join(root, 'AGENTS.md'), content: 'root' },
|
|
24
|
+
{ path: join(app, 'AGENTS.override.md'), content: 'app' },
|
|
25
|
+
]);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('ExecOperations', () => {
|
|
30
|
+
it('reads a path under the directory of this machine as one under the environment', () => {
|
|
31
|
+
const operations = new ExecOperations(new LocalExecEnvironment('/srv/app'), '/home/me/.ta/agent/remote/ssh/dev/srv/app');
|
|
32
|
+
expect(operations.map('/home/me/.ta/agent/remote/ssh/dev/srv/app')).toBe('/srv/app');
|
|
33
|
+
expect(operations.map('/home/me/.ta/agent/remote/ssh/dev/srv/app/src/a.ts')).toBe('/srv/app/src/a.ts');
|
|
34
|
+
expect(operations.map('/home/me/.ta/agent/remote/ssh/dev/srv/apple')).toBe('/home/me/.ta/agent/remote/ssh/dev/srv/apple');
|
|
35
|
+
expect(operations.map('/srv/app/b.ts')).toBe('/srv/app/b.ts');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import type { ExecEnvironment } from '@celljs/ta-exec';
|
|
3
|
+
|
|
4
|
+
export interface ContextFile {
|
|
5
|
+
path: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The context files (AGENTS.md...) of a directory of another environment and of the directories above
|
|
11
|
+
* it, as pi loads them from this machine's: one per directory, the first of pi's names it has, the
|
|
12
|
+
* outermost first. All in one go, so that a host far away costs about one round trip.
|
|
13
|
+
*/
|
|
14
|
+
export namespace RemoteContextFiles {
|
|
15
|
+
/** pi's names, in its order. */
|
|
16
|
+
export const NAMES = ['AGENTS.override.md', 'AGENTS.md', 'AGENTS.MD', 'CLAUDE.md', 'CLAUDE.MD'];
|
|
17
|
+
|
|
18
|
+
/** The directory and those above it, the outermost first. */
|
|
19
|
+
export function directories(cwd: string): string[] {
|
|
20
|
+
const dirs: string[] = [];
|
|
21
|
+
for (let dir = posix.resolve(cwd); ; dir = posix.dirname(dir)) {
|
|
22
|
+
dirs.unshift(dir);
|
|
23
|
+
if (dir === posix.dirname(dir)) {
|
|
24
|
+
return dirs;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function load(environment: ExecEnvironment): Promise<ContextFile[]> {
|
|
30
|
+
const found = await Promise.all(
|
|
31
|
+
directories(environment.cwd).map(async dir => {
|
|
32
|
+
const stats = await Promise.all(NAMES.map(name => environment.stat(posix.join(dir, name)).catch(() => undefined)));
|
|
33
|
+
const index = stats.findIndex(stat => stat && !stat.isDirectory);
|
|
34
|
+
return index < 0 ? undefined : posix.join(dir, NAMES[index]);
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
const files = await Promise.all(
|
|
38
|
+
found.map(async path => {
|
|
39
|
+
if (!path) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
return { path, content: new TextDecoder().decode(await environment.readFile(path)).replace(/^\uFEFF/, '') };
|
|
44
|
+
} catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
return files.filter((file): file is ContextFile => file !== undefined);
|
|
50
|
+
}
|
|
51
|
+
}
|
package/src/node/ta-packages.ts
CHANGED
|
@@ -43,7 +43,15 @@ const PACKAGE_COMMANDS = new Set(['install', 'remove', 'uninstall', 'update', 'l
|
|
|
43
43
|
* directory (PI_PACKAGE_DIR); in the repository they are the workspace packages of {@link BUILTIN}.
|
|
44
44
|
*/
|
|
45
45
|
export namespace TaPackages {
|
|
46
|
-
export const BUILTIN: readonly string[] = [
|
|
46
|
+
export const BUILTIN: readonly string[] = [
|
|
47
|
+
'@celljs/ta-workspace',
|
|
48
|
+
'@celljs/ta-channels',
|
|
49
|
+
'@celljs/ta-extensions',
|
|
50
|
+
'@celljs/ta-computer-use',
|
|
51
|
+
'@celljs/ta-changes',
|
|
52
|
+
'@celljs/ta-cron',
|
|
53
|
+
'@celljs/ta-agents',
|
|
54
|
+
];
|
|
47
55
|
|
|
48
56
|
/** In the agent directory. */
|
|
49
57
|
export const SETTINGS_FILE = 'ta.json';
|