dreamteamer 0.44.0 → 0.44.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/package.json +1 -1
- package/src/events.js +5 -2
- package/src/history.js +13 -1
- package/src/store.js +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dreamteamer",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.1",
|
|
4
4
|
"description": "A workspace compiler for coding agents — schema-validated records as plain files over git, compiled into every harness",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Gilad Khen <giladkhen@gmail.com>",
|
package/src/events.js
CHANGED
|
@@ -7,6 +7,7 @@ import { idFromRecordPath } from './records.js';
|
|
|
7
7
|
import { placedChildAt } from './placement.js';
|
|
8
8
|
|
|
9
9
|
import { storageOf } from './descriptor.js';
|
|
10
|
+
import { commitArg } from './history.js';
|
|
10
11
|
/** Record events between two points, across EVERY repo that holds records. `from` is a sha or a
|
|
11
12
|
* date — a sha is meaningless in another repo, so it is resolved to its commit DATE and each
|
|
12
13
|
* repo then resolves that date to its own sha. Still cursor-less and stores nothing, so it can
|
|
@@ -14,6 +15,7 @@ import { storageOf } from './descriptor.js';
|
|
|
14
15
|
* each record layer's — and an event carries the repo it was read from; sampling the write root
|
|
15
16
|
* alone answered `events: []` for a commit made in a layer's clone. */
|
|
16
17
|
export function deriveEvents(root, descriptors, from, to = 'HEAD') {
|
|
18
|
+
commitArg(to);
|
|
17
19
|
const byRepo = new Map();
|
|
18
20
|
for (const d of descriptors.values()) {
|
|
19
21
|
if (storageOf(d).runtime) continue; // runtime entities aren't item events
|
|
@@ -38,7 +40,7 @@ export function deriveEvents(root, descriptors, from, to = 'HEAD') {
|
|
|
38
40
|
let out = '';
|
|
39
41
|
try {
|
|
40
42
|
out = execFileSync(
|
|
41
|
-
'git', ['diff', '--name-status', '-z', `${fromSha}..${to}`, '--', ...relDirs],
|
|
43
|
+
'git', ['diff', '--name-status', '-z', '--end-of-options', `${fromSha}..${to}`, '--', ...relDirs],
|
|
42
44
|
{ cwd },
|
|
43
45
|
).toString();
|
|
44
46
|
} catch { continue; }
|
|
@@ -59,7 +61,8 @@ function asDate(root, from) {
|
|
|
59
61
|
if (/^\d{4}-\d{2}-\d{2}$/.test(from)) return `${from}T00:00:00`;
|
|
60
62
|
if (/^\d{4}-\d{2}-\d{2}/.test(from)) return from;
|
|
61
63
|
try {
|
|
62
|
-
|
|
64
|
+
commitArg(from, true); // inside the try: a refused revision answers the sentence below
|
|
65
|
+
return execFileSync('git', ['show', '-s', '--format=%cI', '--end-of-options', from], { cwd: root, stdio: ['ignore', 'pipe', 'ignore'] })
|
|
63
66
|
.toString().trim();
|
|
64
67
|
} catch {
|
|
65
68
|
throw new Error(`--since "${from}" is neither a date (YYYY-MM-DD) nor a commit in this workspace`);
|
package/src/history.js
CHANGED
|
@@ -18,6 +18,17 @@ function assertInRepo(descriptor, collection, id) {
|
|
|
18
18
|
|
|
19
19
|
const FORMAT = '%H%x00%an%x00%aI%x00%s';
|
|
20
20
|
|
|
21
|
+
/** A revision a caller hands to git: a commit id (4 to 40 hex digits) or HEAD — with `relative`,
|
|
22
|
+
* also `HEAD~<n>`, the spelling `dt changes --since` documents. git reads a revision that starts
|
|
23
|
+
* with a dash as an option, and some options write files, so anything else is refused before git
|
|
24
|
+
* runs; the argv still puts it after `--end-of-options`. */
|
|
25
|
+
const COMMIT = /^(?:HEAD|[0-9a-fA-F]{4,40})$/;
|
|
26
|
+
const RELATIVE = /^(?:HEAD(?:~\d+)?|[0-9a-fA-F]{4,40})$/;
|
|
27
|
+
export function commitArg(rev, relative = false) {
|
|
28
|
+
if (typeof rev !== 'string' || !(relative ? RELATIVE : COMMIT).test(rev)) throw new Error(`${JSON.stringify(rev)} is not a commit id — give a commit hash (4 to 40 hex digits) or HEAD`);
|
|
29
|
+
return rev;
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
/**
|
|
22
33
|
* The TRACKED file(s) behind a record — what git actually has commits for.
|
|
23
34
|
*
|
|
@@ -69,10 +80,11 @@ export function history(store, collection, id) {
|
|
|
69
80
|
|
|
70
81
|
/** The patch one revision applied to this record. `hash~1` means the ROOT commit has no diff. */
|
|
71
82
|
export function historyDiff(store, collection, id, hash = 'HEAD') {
|
|
83
|
+
commitArg(hash);
|
|
72
84
|
const { file, descriptor } = store.read(collection, id);
|
|
73
85
|
assertInRepo(descriptor, collection, id);
|
|
74
86
|
const cwd = repoOf(store, descriptor, file);
|
|
75
87
|
const paths = trackedPaths(store, file, cwd);
|
|
76
|
-
const diff = execFileSync('git', ['diff', `${hash}~1`, hash, '--', ...paths], { cwd }).toString();
|
|
88
|
+
const diff = execFileSync('git', ['diff', '--end-of-options', `${hash}~1`, hash, '--', ...paths], { cwd }).toString();
|
|
77
89
|
return { hash, path: paths.join(', '), diff };
|
|
78
90
|
}
|
package/src/store.js
CHANGED
|
@@ -16,6 +16,7 @@ import { parseRef } from './namespace.js';
|
|
|
16
16
|
import { relationsOf, expectedMirrors } from './relations.js';
|
|
17
17
|
import { placementOf, placedRecords, rootRecords, placedRoot, placementOfFile, ownerIdOf, symlinkBelow, dirTreeStamps, isNested, parentOfNestedId, localOfNestedId } from './placement.js';
|
|
18
18
|
import { pathToRecord } from './events.js';
|
|
19
|
+
import { commitArg } from './history.js';
|
|
19
20
|
|
|
20
21
|
import { storageOf, fieldsOf, targetsOf, isSoft, jsonSchemaOf, unresolvedPeersOf, bodyFieldOf, idsOf } from './descriptor.js';
|
|
21
22
|
// git calls whose failure we CATCH must not print git's own error: execFileSync forwards the
|
|
@@ -737,6 +738,7 @@ export class Store {
|
|
|
737
738
|
|
|
738
739
|
// restore a record to its content at `hash` — validated like any other write, one commit.
|
|
739
740
|
revert(collection, id, hash) {
|
|
741
|
+
commitArg(hash);
|
|
740
742
|
const d = this.writableDescriptor(collection);
|
|
741
743
|
this.assertUnambiguous(collection, id);
|
|
742
744
|
const { fields: currentFields, file } = this.read(collection, id);
|
|
@@ -749,7 +751,7 @@ export class Store {
|
|
|
749
751
|
const relPath = this.pathAt(d, id, hash) ?? path.relative(fileRepo, file).split(path.sep).join('/');
|
|
750
752
|
let previousContent;
|
|
751
753
|
try {
|
|
752
|
-
previousContent = execFileSync('git', ['show', `${hash}:${relPath}`], { cwd: fileRepo, stdio: QUIET }).toString();
|
|
754
|
+
previousContent = execFileSync('git', ['show', '--end-of-options', `${hash}:${relPath}`], { cwd: fileRepo, stdio: QUIET }).toString();
|
|
753
755
|
} catch {
|
|
754
756
|
throw new Error(`${collection}/${id}: no content at ${hash} for ${relPath} — nothing was reverted.`);
|
|
755
757
|
}
|
|
@@ -1188,7 +1190,7 @@ export class Store {
|
|
|
1188
1190
|
const cwd = path.resolve(this.root, storageOf(d).repo);
|
|
1189
1191
|
const dirs = this.recordDirs(d).map((p) => path.relative(cwd, p));
|
|
1190
1192
|
let out = '';
|
|
1191
|
-
try { out = execFileSync('git', ['ls-tree', '-r', '--name-only', hash, '--', ...dirs], { cwd, stdio: QUIET }).toString(); } catch { return null; }
|
|
1193
|
+
try { out = execFileSync('git', ['ls-tree', '-r', '--name-only', '--end-of-options', hash, '--', ...dirs], { cwd, stdio: QUIET }).toString(); } catch { return null; }
|
|
1192
1194
|
const prefix = (storageOf(d).repo) === '.' ? '' : `${storageOf(d).repo}/`;
|
|
1193
1195
|
for (const p of out.split('\n').filter(Boolean)) {
|
|
1194
1196
|
const rec = pathToRecord(this.descriptors, prefix + p);
|