mossbear 0.1.0-alpha.105 → 0.1.0-alpha.107
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/dist/artifacts/alias-history.d.ts +68 -0
- package/dist/artifacts/alias-history.d.ts.map +1 -0
- package/dist/artifacts/alias-history.js +125 -0
- package/dist/artifacts/alias-history.js.map +1 -0
- package/dist/artifacts/alias-mirror.d.ts +18 -7
- package/dist/artifacts/alias-mirror.d.ts.map +1 -1
- package/dist/artifacts/alias-mirror.js +52 -9
- package/dist/artifacts/alias-mirror.js.map +1 -1
- package/dist/artifacts/artifact-comments.d.ts +8 -2
- package/dist/artifacts/artifact-comments.d.ts.map +1 -1
- package/dist/artifacts/artifact-comments.js +55 -36
- package/dist/artifacts/artifact-comments.js.map +1 -1
- package/dist/artifacts/comments-scope.d.ts.map +1 -1
- package/dist/artifacts/comments-scope.js +2 -2
- package/dist/artifacts/comments-scope.js.map +1 -1
- package/dist/artifacts/delivered-skill-twins.d.ts +117 -0
- package/dist/artifacts/delivered-skill-twins.d.ts.map +1 -0
- package/dist/artifacts/delivered-skill-twins.js +233 -0
- package/dist/artifacts/delivered-skill-twins.js.map +1 -0
- package/dist/artifacts/delivery.d.ts +57 -1
- package/dist/artifacts/delivery.d.ts.map +1 -1
- package/dist/artifacts/delivery.js +99 -5
- package/dist/artifacts/delivery.js.map +1 -1
- package/dist/artifacts/global-sync.d.ts +38 -0
- package/dist/artifacts/global-sync.d.ts.map +1 -0
- package/dist/artifacts/global-sync.js +156 -0
- package/dist/artifacts/global-sync.js.map +1 -0
- package/dist/artifacts/publish-plan.d.ts +1 -0
- package/dist/artifacts/publish-plan.d.ts.map +1 -1
- package/dist/artifacts/publish-plan.js.map +1 -1
- package/dist/artifacts/published-artifacts.d.ts.map +1 -1
- package/dist/artifacts/published-artifacts.js +3 -0
- package/dist/artifacts/published-artifacts.js.map +1 -1
- package/dist/artifacts/repo-config.d.ts +14 -1
- package/dist/artifacts/repo-config.d.ts.map +1 -1
- package/dist/artifacts/repo-config.js +42 -7
- package/dist/artifacts/repo-config.js.map +1 -1
- package/dist/artifacts/skill-twins.d.ts.map +1 -1
- package/dist/artifacts/skill-twins.js +4 -8
- package/dist/artifacts/skill-twins.js.map +1 -1
- package/dist/artifacts/status.d.ts +15 -0
- package/dist/artifacts/status.d.ts.map +1 -1
- package/dist/artifacts/status.js +44 -5
- package/dist/artifacts/status.js.map +1 -1
- package/dist/artifacts/subscribe.d.ts.map +1 -1
- package/dist/artifacts/subscribe.js +10 -3
- package/dist/artifacts/subscribe.js.map +1 -1
- package/dist/artifacts/sync-artifacts.d.ts +38 -95
- package/dist/artifacts/sync-artifacts.d.ts.map +1 -1
- package/dist/artifacts/sync-artifacts.js +81 -291
- package/dist/artifacts/sync-artifacts.js.map +1 -1
- package/dist/artifacts/sync-execution.d.ts +31 -0
- package/dist/artifacts/sync-execution.d.ts.map +1 -1
- package/dist/artifacts/sync-execution.js +112 -8
- package/dist/artifacts/sync-execution.js.map +1 -1
- package/dist/artifacts/sync-plan.d.ts +32 -0
- package/dist/artifacts/sync-plan.d.ts.map +1 -1
- package/dist/artifacts/sync-plan.js +37 -1
- package/dist/artifacts/sync-plan.js.map +1 -1
- package/dist/commands/artifacts/remote.d.ts +8 -0
- package/dist/commands/artifacts/remote.d.ts.map +1 -1
- package/dist/commands/artifacts/remote.js +1 -1
- package/dist/commands/artifacts/remote.js.map +1 -1
- package/dist/commands/comments.d.ts.map +1 -1
- package/dist/commands/comments.js +1 -1
- package/dist/commands/comments.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +12 -20
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts +0 -5
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +14 -192
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/promote.d.ts.map +1 -1
- package/dist/commands/promote.js +2 -2
- package/dist/commands/promote.js.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +48 -3
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/pull.d.ts +26 -0
- package/dist/commands/pull.d.ts.map +1 -1
- package/dist/commands/pull.js +92 -6
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +15 -3
- package/dist/commands/status.js.map +1 -1
- package/dist/config.d.ts +1 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +148 -227
- package/dist/config.js.map +1 -1
- package/dist/lifecycle/landed-revisions.d.ts +77 -0
- package/dist/lifecycle/landed-revisions.d.ts.map +1 -0
- package/dist/lifecycle/landed-revisions.js +273 -0
- package/dist/lifecycle/landed-revisions.js.map +1 -0
- package/dist/lifecycle/operations.d.ts.map +1 -1
- package/dist/lifecycle/operations.js +26 -9
- package/dist/lifecycle/operations.js.map +1 -1
- package/dist/lifecycle/publish-from-branch.d.ts.map +1 -1
- package/dist/lifecycle/publish-from-branch.js +27 -0
- package/dist/lifecycle/publish-from-branch.js.map +1 -1
- package/dist/lifecycle/retire-skipped-drafts.d.ts +48 -0
- package/dist/lifecycle/retire-skipped-drafts.d.ts.map +1 -0
- package/dist/lifecycle/retire-skipped-drafts.js +100 -0
- package/dist/lifecycle/retire-skipped-drafts.js.map +1 -0
- package/dist/mcp/client.d.ts +19 -2
- package/dist/mcp/client.d.ts.map +1 -1
- package/dist/mcp/client.js +26 -4
- package/dist/mcp/client.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +63 -10
- package/dist/mcp/server.js.map +1 -1
- package/dist/mossbear-paths.d.ts +1 -1
- package/dist/mossbear-paths.js +1 -1
- package/dist/rules/adoption-nudge.d.ts +9 -8
- package/dist/rules/adoption-nudge.d.ts.map +1 -1
- package/dist/rules/adoption-nudge.js +9 -8
- package/dist/rules/adoption-nudge.js.map +1 -1
- package/dist/rules/bundled-skills.d.ts +60 -30
- package/dist/rules/bundled-skills.d.ts.map +1 -1
- package/dist/rules/bundled-skills.js +161 -46
- package/dist/rules/bundled-skills.js.map +1 -1
- package/dist/rules/import-candidates.d.ts +37 -6
- package/dist/rules/import-candidates.d.ts.map +1 -1
- package/dist/rules/import-candidates.js +109 -9
- package/dist/rules/import-candidates.js.map +1 -1
- package/dist/rules/shipped-skill-hashes.d.ts +19 -0
- package/dist/rules/shipped-skill-hashes.d.ts.map +1 -0
- package/dist/rules/shipped-skill-hashes.js +91 -0
- package/dist/rules/shipped-skill-hashes.js.map +1 -0
- package/dist/state/machine-cache.d.ts +1 -1
- package/dist/state/machine-cache.js +1 -1
- package/dist/update/assets.d.ts +8 -37
- package/dist/update/assets.d.ts.map +1 -1
- package/dist/update/assets.js +5 -83
- package/dist/update/assets.js.map +1 -1
- package/dist/update/perform.d.ts +10 -5
- package/dist/update/perform.d.ts.map +1 -1
- package/dist/update/perform.js +42 -36
- package/dist/update/perform.js.map +1 -1
- package/dist/usage/snapshot-admission.d.ts +30 -0
- package/dist/usage/snapshot-admission.d.ts.map +1 -0
- package/dist/usage/snapshot-admission.js +33 -0
- package/dist/usage/snapshot-admission.js.map +1 -0
- package/dist/usage/startup-policy.d.ts +17 -0
- package/dist/usage/startup-policy.d.ts.map +1 -0
- package/dist/usage/startup-policy.js +53 -0
- package/dist/usage/startup-policy.js.map +1 -0
- package/package.json +4 -4
- package/dist/skill-template.d.ts +0 -51
- package/dist/skill-template.d.ts.map +0 -1
- package/dist/skill-template.js +0 -415
- package/dist/skill-template.js.map +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which file of a divergent alias set was edited, answered from git history.
|
|
3
|
+
*
|
|
4
|
+
* `deriveAliasMirrors` picks its source from a file with an uncommitted edit.
|
|
5
|
+
* An agent commits inside its own turn and the sync runs at the next session
|
|
6
|
+
* start, so by then the edit is committed on one side and the set sits
|
|
7
|
+
* divergent for good. History still holds the answer: the newest commit at
|
|
8
|
+
* which every file of the set held the same bytes is the last point the pair was
|
|
9
|
+
* in step, and the one file that has changed since is the edit to carry over.
|
|
10
|
+
*
|
|
11
|
+
* Three answers are not an answer, and each is reported as such rather than
|
|
12
|
+
* guessed:
|
|
13
|
+
*
|
|
14
|
+
* - **Several files changed since the common point** — someone edited both
|
|
15
|
+
* sides, and only they can say which is right.
|
|
16
|
+
* - **No commit where the files matched**, within a bounded window of history
|
|
17
|
+
* (`HISTORY_WINDOW` commits that touched the set).
|
|
18
|
+
* - **Git cannot answer** — no work tree, git missing, a timeout, framing this
|
|
19
|
+
* parser does not know. This follows `committed.ts`: a failure resolves to
|
|
20
|
+
* "nothing to say", never to a thrown error that fails the sync.
|
|
21
|
+
*
|
|
22
|
+
* A shallow clone is named separately from the other two, because the fix for
|
|
23
|
+
* it is to fetch more history, and "no common point" would send the reader to
|
|
24
|
+
* look for a divergence that may not exist.
|
|
25
|
+
*
|
|
26
|
+
* Reads only; it never writes, and it compares the blobs git recorded, not the
|
|
27
|
+
* working bytes — the caller has already established that every file in the set
|
|
28
|
+
* holds its committed content.
|
|
29
|
+
*/
|
|
30
|
+
import type { SpawnGitBytesFn } from './committed.js';
|
|
31
|
+
/** Commits that touched the set, newest first, that are inspected before giving up. */
|
|
32
|
+
export declare const HISTORY_WINDOW = 200;
|
|
33
|
+
export type AliasHistoryAnswer =
|
|
34
|
+
/** Exactly one file changed since the files last matched. */
|
|
35
|
+
{
|
|
36
|
+
kind: 'source';
|
|
37
|
+
path: string;
|
|
38
|
+
}
|
|
39
|
+
/** More than one file changed since the files last matched. */
|
|
40
|
+
| {
|
|
41
|
+
kind: 'several';
|
|
42
|
+
paths: string[];
|
|
43
|
+
}
|
|
44
|
+
/** The files never matched within the window, or the window is all there is. */
|
|
45
|
+
| {
|
|
46
|
+
kind: 'no-common-point';
|
|
47
|
+
}
|
|
48
|
+
/** The history ends at a shallow boundary before the files were found to match. */
|
|
49
|
+
| {
|
|
50
|
+
kind: 'shallow';
|
|
51
|
+
}
|
|
52
|
+
/** Git could not answer. */
|
|
53
|
+
| {
|
|
54
|
+
kind: 'no-answer';
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Find the edited file of a set whose files all match `HEAD` but differ.
|
|
58
|
+
*
|
|
59
|
+
* `headBlobs` is what the caller already read for each path at `HEAD`, so this
|
|
60
|
+
* does not ask again. It must hold every path in `paths`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function findEditedFileFromHistory(input: {
|
|
63
|
+
root: string;
|
|
64
|
+
paths: readonly string[];
|
|
65
|
+
headBlobs: ReadonlyMap<string, string>;
|
|
66
|
+
spawnGit?: SpawnGitBytesFn;
|
|
67
|
+
}): AliasHistoryAnswer;
|
|
68
|
+
//# sourceMappingURL=alias-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alias-history.d.ts","sourceRoot":"","sources":["../../src/artifacts/alias-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,uFAAuF;AACvF,eAAO,MAAM,cAAc,MAAM,CAAA;AAKjC,MAAM,MAAM,kBAAkB;AAC5B,6DAA6D;AAC3D;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAClC,+DAA+D;GAC7D;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE;AACtC,gFAAgF;GAC9E;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE;AAC7B,mFAAmF;GACjF;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;AACrB,4BAA4B;GAC1B;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAA;AAYzB;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;IACxB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACtC,QAAQ,CAAC,EAAE,eAAe,CAAA;CAC3B,GAAG,kBAAkB,CAoFrB"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which file of a divergent alias set was edited, answered from git history.
|
|
3
|
+
*
|
|
4
|
+
* `deriveAliasMirrors` picks its source from a file with an uncommitted edit.
|
|
5
|
+
* An agent commits inside its own turn and the sync runs at the next session
|
|
6
|
+
* start, so by then the edit is committed on one side and the set sits
|
|
7
|
+
* divergent for good. History still holds the answer: the newest commit at
|
|
8
|
+
* which every file of the set held the same bytes is the last point the pair was
|
|
9
|
+
* in step, and the one file that has changed since is the edit to carry over.
|
|
10
|
+
*
|
|
11
|
+
* Three answers are not an answer, and each is reported as such rather than
|
|
12
|
+
* guessed:
|
|
13
|
+
*
|
|
14
|
+
* - **Several files changed since the common point** — someone edited both
|
|
15
|
+
* sides, and only they can say which is right.
|
|
16
|
+
* - **No commit where the files matched**, within a bounded window of history
|
|
17
|
+
* (`HISTORY_WINDOW` commits that touched the set).
|
|
18
|
+
* - **Git cannot answer** — no work tree, git missing, a timeout, framing this
|
|
19
|
+
* parser does not know. This follows `committed.ts`: a failure resolves to
|
|
20
|
+
* "nothing to say", never to a thrown error that fails the sync.
|
|
21
|
+
*
|
|
22
|
+
* A shallow clone is named separately from the other two, because the fix for
|
|
23
|
+
* it is to fetch more history, and "no common point" would send the reader to
|
|
24
|
+
* look for a divergence that may not exist.
|
|
25
|
+
*
|
|
26
|
+
* Reads only; it never writes, and it compares the blobs git recorded, not the
|
|
27
|
+
* working bytes — the caller has already established that every file in the set
|
|
28
|
+
* holds its committed content.
|
|
29
|
+
*/
|
|
30
|
+
import { spawnSync } from 'node:child_process';
|
|
31
|
+
import { parseCatFileBatch } from './committed.js';
|
|
32
|
+
/** Commits that touched the set, newest first, that are inspected before giving up. */
|
|
33
|
+
export const HISTORY_WINDOW = 200;
|
|
34
|
+
/** Commits whose blobs one `cat-file` process reads. */
|
|
35
|
+
const COMMITS_PER_BATCH = 20;
|
|
36
|
+
function defaultSpawnGit(args, cwd, input) {
|
|
37
|
+
const result = spawnSync('git', [...args], {
|
|
38
|
+
cwd,
|
|
39
|
+
input: Buffer.from(input, 'utf8'),
|
|
40
|
+
timeout: 10_000,
|
|
41
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
42
|
+
});
|
|
43
|
+
return { status: result.status, stdout: result.stdout ?? Buffer.alloc(0) };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Find the edited file of a set whose files all match `HEAD` but differ.
|
|
47
|
+
*
|
|
48
|
+
* `headBlobs` is what the caller already read for each path at `HEAD`, so this
|
|
49
|
+
* does not ask again. It must hold every path in `paths`.
|
|
50
|
+
*/
|
|
51
|
+
export function findEditedFileFromHistory(input) {
|
|
52
|
+
const { root, paths, headBlobs, spawnGit = defaultSpawnGit } = input;
|
|
53
|
+
if (paths.length < 2)
|
|
54
|
+
return { kind: 'no-answer' };
|
|
55
|
+
// A path with a newline would forge a second request line in the batch below.
|
|
56
|
+
if (paths.some((path) => path.includes('\n') || path.includes('\0'))) {
|
|
57
|
+
return { kind: 'no-answer' };
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const log = spawnGit([
|
|
61
|
+
'--no-optional-locks',
|
|
62
|
+
'--literal-pathspecs',
|
|
63
|
+
'log',
|
|
64
|
+
// Without it git drops a merge commit whose state matches a parent's,
|
|
65
|
+
// and the walk can pass over the very commit that reconciled the pair.
|
|
66
|
+
'--full-history',
|
|
67
|
+
'--format=%H',
|
|
68
|
+
'-n',
|
|
69
|
+
String(HISTORY_WINDOW),
|
|
70
|
+
'--',
|
|
71
|
+
...paths,
|
|
72
|
+
], root, '');
|
|
73
|
+
if (log.status !== 0)
|
|
74
|
+
return { kind: 'no-answer' };
|
|
75
|
+
const commits = log.stdout
|
|
76
|
+
.toString('utf8')
|
|
77
|
+
.split('\n')
|
|
78
|
+
.filter((line) => line !== '');
|
|
79
|
+
if (commits.length === 0)
|
|
80
|
+
return { kind: 'no-common-point' };
|
|
81
|
+
// A few commits per `cat-file` process, newest first: the usual common point
|
|
82
|
+
// is within the first handful, and a long history of large guide files
|
|
83
|
+
// should not be read whole to find it.
|
|
84
|
+
for (let start = 0; start < commits.length; start += COMMITS_PER_BATCH) {
|
|
85
|
+
const batchCommits = commits.slice(start, start + COMMITS_PER_BATCH);
|
|
86
|
+
const requests = batchCommits.flatMap((commit) => paths.map((path) => `${commit}:${path}`));
|
|
87
|
+
const batch = spawnGit(['--no-optional-locks', 'cat-file', '--batch'], root, `${requests.join('\n')}\n`);
|
|
88
|
+
if (batch.status !== 0)
|
|
89
|
+
return { kind: 'no-answer' };
|
|
90
|
+
const records = parseCatFileBatch(batch.stdout, requests.length);
|
|
91
|
+
if (records === null)
|
|
92
|
+
return { kind: 'no-answer' };
|
|
93
|
+
for (const [commitIndex] of batchCommits.entries()) {
|
|
94
|
+
const blobs = paths.map((_, pathIndex) => {
|
|
95
|
+
const record = records[commitIndex * paths.length + pathIndex];
|
|
96
|
+
return record === null || record === undefined
|
|
97
|
+
? undefined
|
|
98
|
+
: record.blob.toString('utf8');
|
|
99
|
+
});
|
|
100
|
+
const common = blobs[0];
|
|
101
|
+
if (common === undefined || blobs.some((blob) => blob !== common))
|
|
102
|
+
continue;
|
|
103
|
+
// The newest commit at which the whole set matched. What differs from it
|
|
104
|
+
// now is the edit.
|
|
105
|
+
const changed = paths.filter((path) => headBlobs.get(path) !== common);
|
|
106
|
+
if (changed.length === 1 && changed[0] !== undefined) {
|
|
107
|
+
return { kind: 'source', path: changed[0] };
|
|
108
|
+
}
|
|
109
|
+
if (changed.length > 1)
|
|
110
|
+
return { kind: 'several', paths: changed };
|
|
111
|
+
// Nothing changed since: the set matches at HEAD, which the caller ruled out.
|
|
112
|
+
return { kind: 'no-answer' };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const shallow = spawnGit(['--no-optional-locks', 'rev-parse', '--is-shallow-repository'], root, '');
|
|
116
|
+
if (shallow.status === 0 && shallow.stdout.toString('utf8').trim() === 'true') {
|
|
117
|
+
return { kind: 'shallow' };
|
|
118
|
+
}
|
|
119
|
+
return { kind: 'no-common-point' };
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return { kind: 'no-answer' };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=alias-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alias-history.js","sourceRoot":"","sources":["../../src/artifacts/alias-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIlD,uFAAuF;AACvF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;AAEjC,wDAAwD;AACxD,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAc5B,SAAS,eAAe,CAAC,IAAuB,EAAE,GAAW,EAAE,KAAa;IAC1E,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;QACzC,GAAG;QACH,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC;QACjC,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;KAC5B,CAAC,CAAA;IACF,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAC5E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAKzC;IACC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE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,CAAC;oBAAE,SAAQ;gBAE3E,yEAAyE;gBACzE,mBAAmB;gBACnB,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAA;gBACtE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;oBACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;gBAC7C,CAAC;gBACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;oBAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;gBAClE,8EAA8E;gBAC9E,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;YAC9B,CAAC;QACH,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,CACtB,CAAC,qBAAqB,EAAE,WAAW,EAAE,yBAAyB,CAAC,EAC/D,IAAI,EACJ,EAAE,CACH,CAAA;QACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;YAC9E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;QAC5B,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAA;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -27,11 +27,15 @@
|
|
|
27
27
|
* exists to prevent, reported as the feature working. Found by the automated
|
|
28
28
|
* reviewer on #1240, which reproduced it against this module.
|
|
29
29
|
*
|
|
30
|
-
* When **no** file has an uncommitted change
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* When **no** file has an uncommitted change and the files differ, the edit may
|
|
31
|
+
* already be committed — an agent commits inside its own turn, and this runs at
|
|
32
|
+
* the next session start. Git history then names the source: the newest commit at
|
|
33
|
+
* which every file in the set held the same bytes, and the one file that has
|
|
34
|
+
* changed since (`./alias-history.ts`). Exactly one changed → it is the source.
|
|
35
|
+
* More than one → `several-edited`. No such commit within the window, a shallow
|
|
36
|
+
* clone that ends before it, or no answer from git → `no-local-source`, which
|
|
37
|
+
* writes nothing. When **several** files have an uncommitted change, the user is
|
|
38
|
+
* editing both and there is no source to pick. Each is named, and none writes.
|
|
35
39
|
*
|
|
36
40
|
* **`CLAUDE.md` is never part of a set here**, whatever the server sends.
|
|
37
41
|
* Mossbear owns `AGENTS.md`; a `CLAUDE.md` imports it (`@AGENTS.md`) rather
|
|
@@ -77,6 +81,7 @@
|
|
|
77
81
|
* `attendedProjectWrite` to get through the gate would widen the gate for
|
|
78
82
|
* everything else too, which is why this runs beside it rather than through it.
|
|
79
83
|
*/
|
|
84
|
+
import { findEditedFileFromHistory } from './alias-history.js';
|
|
80
85
|
import type { CommittedProbe } from './committed.js';
|
|
81
86
|
import type { GuideProjectionDeps } from './guide-projection.js';
|
|
82
87
|
import type { ConflictResolution } from './sync-plan.js';
|
|
@@ -95,9 +100,13 @@ export type AliasMirrorOutcome =
|
|
|
95
100
|
| 'in-sync'
|
|
96
101
|
/** The target carries uncommitted changes; writing would lose what git cannot give back. */
|
|
97
102
|
| 'held-uncommitted'
|
|
98
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* The files differ, none has an uncommitted change, and git history does not
|
|
105
|
+
* name the edited one: no commit where they matched within the window, a
|
|
106
|
+
* shallow clone, a file git has no record of, or no answer from git.
|
|
107
|
+
*/
|
|
99
108
|
| 'no-local-source'
|
|
100
|
-
/** Several files
|
|
109
|
+
/** Several files changed — uncommitted, or committed since the files last matched — so which one is the edit is not knowable. */
|
|
101
110
|
| 'several-edited'
|
|
102
111
|
/** The path resolves outside the repo or through a symlink. */
|
|
103
112
|
| 'unsafe-path'
|
|
@@ -112,6 +121,8 @@ export type AliasMirrorResult = {
|
|
|
112
121
|
error?: string;
|
|
113
122
|
};
|
|
114
123
|
export type AliasMirrorDeps = GuideProjectionDeps & {
|
|
124
|
+
/** Replaces the git history lookup, for tests that fake git. */
|
|
125
|
+
findEditedFileFn?: typeof findEditedFileFromHistory;
|
|
115
126
|
readFileFn?: (path: string, encoding: 'utf8') => Promise<string>;
|
|
116
127
|
writeFileFn?: (path: string, data: string) => Promise<void>;
|
|
117
128
|
mkdirFn?: (path: string, options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias-mirror.d.ts","sourceRoot":"","sources":["../../src/artifacts/alias-mirror.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"alias-mirror.d.ts","sourceRoot":"","sources":["../../src/artifacts/alias-mirror.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AAMH,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAK9D,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAA;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAExD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,mFAAmF;IACnF,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,kBAAkB;AAC5B,sCAAsC;AACpC,SAAS;AACX,uCAAuC;GACrC,SAAS;AACX,4FAA4F;GAC1F,kBAAkB;AACpB;;;;GAIG;GACD,iBAAiB;AACnB,iIAAiI;GAC/H,gBAAgB;AAClB,+DAA+D;GAC7D,aAAa;AACf,+BAA+B;GAC7B,QAAQ,CAAA;AAEZ,MAAM,MAAM,iBAAiB,GAAG;IAC9B,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAA;IACZ,uFAAuF;IACvF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,kBAAkB,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG;IAClD,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,OAAO,yBAAyB,CAAA;IACnD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAChE,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3D,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,SAAS,EAAE,IAAI,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACtF,CAAA;AAgDD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,gBAAgB,EAAE,CAAA;IACnC,iFAAiF;IACjF,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,4EAA4E;IAC5E,SAAS,EAAE,cAAc,CAAA;IACzB,IAAI,CAAC,EAAE,eAAe,CAAA;CACvB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CA6H/B"}
|
|
@@ -27,11 +27,15 @@
|
|
|
27
27
|
* exists to prevent, reported as the feature working. Found by the automated
|
|
28
28
|
* reviewer on #1240, which reproduced it against this module.
|
|
29
29
|
*
|
|
30
|
-
* When **no** file has an uncommitted change
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* When **no** file has an uncommitted change and the files differ, the edit may
|
|
31
|
+
* already be committed — an agent commits inside its own turn, and this runs at
|
|
32
|
+
* the next session start. Git history then names the source: the newest commit at
|
|
33
|
+
* which every file in the set held the same bytes, and the one file that has
|
|
34
|
+
* changed since (`./alias-history.ts`). Exactly one changed → it is the source.
|
|
35
|
+
* More than one → `several-edited`. No such commit within the window, a shallow
|
|
36
|
+
* clone that ends before it, or no answer from git → `no-local-source`, which
|
|
37
|
+
* writes nothing. When **several** files have an uncommitted change, the user is
|
|
38
|
+
* editing both and there is no source to pick. Each is named, and none writes.
|
|
35
39
|
*
|
|
36
40
|
* **`CLAUDE.md` is never part of a set here**, whatever the server sends.
|
|
37
41
|
* Mossbear owns `AGENTS.md`; a `CLAUDE.md` imports it (`@AGENTS.md`) rather
|
|
@@ -80,6 +84,7 @@
|
|
|
80
84
|
import { mkdir, readFile } from 'node:fs/promises';
|
|
81
85
|
import { dirname, resolve } from 'node:path';
|
|
82
86
|
import { writeContextFile } from '../context/materialize.js';
|
|
87
|
+
import { findEditedFileFromHistory } from './alias-history.js';
|
|
83
88
|
import { isRootClaudeMd } from './claude-md-import.js';
|
|
84
89
|
import { refuseUnsafeMappedTarget } from './guide-projection.js';
|
|
85
90
|
const errText = (err) => err instanceof Error ? err.message : String(err);
|
|
@@ -98,6 +103,26 @@ async function readWorking(absolutePath, readFileFn) {
|
|
|
98
103
|
return undefined;
|
|
99
104
|
}
|
|
100
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Ask history which file of a divergent, fully committed set was edited.
|
|
108
|
+
*
|
|
109
|
+
* Only a set whose every file holds its committed bytes can be answered this
|
|
110
|
+
* way: an untracked file, or one git has no answer for, has no history to read.
|
|
111
|
+
*/
|
|
112
|
+
function readHistory(root, present, states, deps) {
|
|
113
|
+
const headBlobs = new Map();
|
|
114
|
+
for (const file of present) {
|
|
115
|
+
const state = states.get(file.path);
|
|
116
|
+
if (state?.kind !== 'committed')
|
|
117
|
+
return { kind: 'no-answer' };
|
|
118
|
+
headBlobs.set(file.path, state.blob);
|
|
119
|
+
}
|
|
120
|
+
return (deps.findEditedFileFn ?? findEditedFileFromHistory)({
|
|
121
|
+
root,
|
|
122
|
+
paths: present.map((file) => file.path),
|
|
123
|
+
headBlobs,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
101
126
|
/**
|
|
102
127
|
* Rewrite every file in each guide's alias set from the one that already holds
|
|
103
128
|
* what the server holds.
|
|
@@ -157,19 +182,37 @@ export async function deriveAliasMirrors(input) {
|
|
|
157
182
|
});
|
|
158
183
|
continue;
|
|
159
184
|
}
|
|
160
|
-
|
|
185
|
+
let source = edited[0];
|
|
161
186
|
if (source === undefined) {
|
|
162
|
-
// Nothing
|
|
187
|
+
// Nothing is uncommitted. Reported only when the files actually differ:
|
|
163
188
|
// an in-sync set with no edit is the ordinary steady state and has
|
|
164
189
|
// nothing to say.
|
|
165
190
|
const differ = present.some((file) => file.content !== present[0]?.content);
|
|
166
|
-
if (differ)
|
|
191
|
+
if (!differ)
|
|
192
|
+
continue;
|
|
193
|
+
// The edit may already be committed — an agent commits inside its own
|
|
194
|
+
// turn, and this runs at the next session start. History says which
|
|
195
|
+
// file moved since the set last matched (`./alias-history.ts`).
|
|
196
|
+
const history = readHistory(root, present, states, deps);
|
|
197
|
+
if (history.kind === 'several') {
|
|
198
|
+
results.push({ path: history.paths.join(', '), outcome: 'several-edited' });
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (history.kind !== 'source') {
|
|
167
202
|
results.push({
|
|
168
203
|
path: present.map((file) => file.path).join(', '),
|
|
169
204
|
outcome: 'no-local-source',
|
|
205
|
+
...(history.kind === 'shallow'
|
|
206
|
+
? {
|
|
207
|
+
error: 'this clone is shallow and its history ends before the files last matched',
|
|
208
|
+
}
|
|
209
|
+
: {}),
|
|
170
210
|
});
|
|
211
|
+
continue;
|
|
171
212
|
}
|
|
172
|
-
|
|
213
|
+
source = present.find((file) => file.path === history.path);
|
|
214
|
+
if (source === undefined)
|
|
215
|
+
continue;
|
|
173
216
|
}
|
|
174
217
|
for (const target of present) {
|
|
175
218
|
if (target.path === source.path)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alias-mirror.js","sourceRoot":"","sources":["../../src/artifacts/alias-mirror.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"alias-mirror.js","sourceRoot":"","sources":["../../src/artifacts/alias-mirror.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAqDhE,MAAM,OAAO,GAAG,CAAC,GAAY,EAAU,EAAE,CACvC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAElD;;;;;;GAMG;AACH,KAAK,UAAU,WAAW,CACxB,YAAoB,EACpB,UAAsD;IAEtD,IAAI,CAAC;QACH,OAAO,MAAM,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED;;;;;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AE,MAAM,CAAC,IAAI;oBACjB,MAAM,EAAE,MAAM,CAAC,IAAI;oBACnB,OAAO,EAAE,kBAAkB;iBAC5B,CAAC,CAAA;gBACF,SAAQ;YACV,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;gBAChE,MAAM,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;gBACtD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;YAC9E,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC;oBACX,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,MAAM,EAAE,MAAM,CAAC,IAAI;oBACnB,OAAO,EAAE,QAAQ;oBACjB,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC;iBACpB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -39,8 +39,14 @@ export declare const CHANGED_SINCE_READ_LINE = "the guide changed since you last
|
|
|
39
39
|
* reply is a request, an agent's is context) is the server's `untrusted.note`.
|
|
40
40
|
*/
|
|
41
41
|
export declare const THREADS_HEADING = "Threads, by who wrote each reply (said here, where no comment text can reach; resolve a thread by its own id, not a reply\u2019s):";
|
|
42
|
-
/**
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Compact on-demand rendering: one marked block, grouped by artifact.
|
|
44
|
+
*
|
|
45
|
+
* Every id is printed whole. A prefix sized to make one read's ids unique is
|
|
46
|
+
* one no other surface can reproduce, and the Inbox's prompt names findings by
|
|
47
|
+
* their full ids, so a shortened id here was a second form to mis-copy.
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatCompactComments(received: readonly ItemCommentWithSubject[], cursor: string, untrusted: GuideHistoryUntrusted | null | undefined): string;
|
|
44
50
|
/**
|
|
45
51
|
* One comment, as the docs phase saw it: about an item this repo actually
|
|
46
52
|
* received, with the body exactly as the server delimited it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact-comments.d.ts","sourceRoot":"","sources":["../../src/artifacts/artifact-comments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAEvF;;;GAGG;AACH,eAAO,MAAM,UAAU,gFACwD,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qIACgG,CAAA;AAEpI;;;GAGG;AACH,eAAO,MAAM,eAAe,uIACqG,CAAA;
|
|
1
|
+
{"version":3,"file":"artifact-comments.d.ts","sourceRoot":"","sources":["../../src/artifacts/artifact-comments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAEvF;;;GAGG;AACH,eAAO,MAAM,UAAU,gFACwD,CAAA;AAE/E;;;GAGG;AACH,eAAO,MAAM,uBAAuB,qIACgG,CAAA;AAEpI;;;GAGG;AACH,eAAO,MAAM,eAAe,uIACqG,CAAA;AAkHjI;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,sBAAsB,EAAE,EAC3C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,GAClD,MAAM,CAwHR;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,iFAAiF;IACjF,EAAE,EAAE,MAAM,CAAA;IACV,2DAA2D;IAC3D,Q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CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC3C,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAAG,SAAS,CAAA;IAC7D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACrC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACrC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,GAC5C,wBAAwB,EAAE,CAS5B;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,EAC7C,OAAO,GAAE,MAAwB,GAChC,MAAM,EAAE,CAoCV;AA8DD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE;IACrD,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,MAAM,EAAE,CAQX"}
|
|
@@ -40,9 +40,37 @@ export const CHANGED_SINCE_READ_LINE = "the guide changed since you last read th
|
|
|
40
40
|
* reply is a request, an agent's is context) is the server's `untrusted.note`.
|
|
41
41
|
*/
|
|
42
42
|
export const THREADS_HEADING = 'Threads, by who wrote each reply (said here, where no comment text can reach; resolve a thread by its own id, not a reply’s):';
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* An open Mossbear finding that waits on the person. The server says so in
|
|
45
|
+
* `findingState`, which also counts a finding whose evidence makes it ready
|
|
46
|
+
* without Accept. A server that predates the field sends only `approved`, so
|
|
47
|
+
* that is the fallback.
|
|
48
|
+
*/
|
|
44
49
|
function isDraft(comment) {
|
|
45
|
-
|
|
50
|
+
if (comment.state === 'resolved')
|
|
51
|
+
return false;
|
|
52
|
+
if (comment.findingState !== undefined)
|
|
53
|
+
return comment.findingState === 'waiting';
|
|
54
|
+
return comment.approved === false;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Where a comment's artifact is published from, as one line, or null when the
|
|
58
|
+
* server records no publishing repo. Another repo's artifact is changed there,
|
|
59
|
+
* so the line says so: "resolve once it lands" means that repo's branch.
|
|
60
|
+
*/
|
|
61
|
+
function publishedFromLine(comment) {
|
|
62
|
+
const source = comment.publishedFrom;
|
|
63
|
+
if (!source)
|
|
64
|
+
return null;
|
|
65
|
+
// The publisher named the branch and the repo id, so a control character in
|
|
66
|
+
// either is escaped rather than printed, and cannot start a line of its own.
|
|
67
|
+
const branch = source.branch === null ? '' : `, branch ${displayFileName(source.branch)}`;
|
|
68
|
+
if (source.thisRepo === true)
|
|
69
|
+
return `published from this repo${branch}`;
|
|
70
|
+
const repo = `repo ${displayFileName(source.repository ?? source.projectId)}${branch}`;
|
|
71
|
+
return source.thisRepo === false
|
|
72
|
+
? `published from another ${repo}: make the change there, not here`
|
|
73
|
+
: `published from ${repo}`;
|
|
46
74
|
}
|
|
47
75
|
/** A reply in a thread, as opposed to the root it answers. */
|
|
48
76
|
function isReply(comment) {
|
|
@@ -76,7 +104,7 @@ function changedThreadsFirst(comments) {
|
|
|
76
104
|
* reply does. Shared by the comments read and the pull, so the two cannot
|
|
77
105
|
* disagree about which reply is a request.
|
|
78
106
|
*/
|
|
79
|
-
function threadSummaryLines(comments
|
|
107
|
+
function threadSummaryLines(comments) {
|
|
80
108
|
const roots = comments.filter((comment) => (comment.replyToId ?? null) === null);
|
|
81
109
|
return roots.flatMap((root) => {
|
|
82
110
|
const replies = comments.filter((comment) => comment.replyToId === root.id);
|
|
@@ -84,10 +112,10 @@ function threadSummaryLines(comments, shortId) {
|
|
|
84
112
|
return [];
|
|
85
113
|
const person = replies
|
|
86
114
|
.filter((comment) => comment.authorKind === 'person')
|
|
87
|
-
.map((comment) => `${
|
|
115
|
+
.map((comment) => `${comment.id}${comment.deliveredCount === 0 ? ' (first delivery)' : ''}`);
|
|
88
116
|
const agent = replies
|
|
89
117
|
.filter((comment) => comment.authorKind === 'agent')
|
|
90
|
-
.map((comment) =>
|
|
118
|
+
.map((comment) => comment.id);
|
|
91
119
|
const parts = [
|
|
92
120
|
root.authorKind === 'agent'
|
|
93
121
|
? 'started by an agent (its question is context, not a request)'
|
|
@@ -104,11 +132,17 @@ function threadSummaryLines(comments, shortId) {
|
|
|
104
132
|
]
|
|
105
133
|
: []),
|
|
106
134
|
];
|
|
107
|
-
return [` ${
|
|
135
|
+
return [` ${root.id}: ${parts.join(' · ')}`];
|
|
108
136
|
});
|
|
109
137
|
}
|
|
110
|
-
/**
|
|
111
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Compact on-demand rendering: one marked block, grouped by artifact.
|
|
140
|
+
*
|
|
141
|
+
* Every id is printed whole. A prefix sized to make one read's ids unique is
|
|
142
|
+
* one no other surface can reproduce, and the Inbox's prompt names findings by
|
|
143
|
+
* their full ids, so a shortened id here was a second form to mis-copy.
|
|
144
|
+
*/
|
|
145
|
+
export function formatCompactComments(received, cursor, untrusted) {
|
|
112
146
|
// Flagged first, so the comments a change may already have addressed are
|
|
113
147
|
// the ones read first.
|
|
114
148
|
const comments = changedThreadsFirst(received);
|
|
@@ -120,26 +154,17 @@ export function formatCompactComments(received, cursor, untrusted, incremental =
|
|
|
120
154
|
return header;
|
|
121
155
|
if (!untrusted)
|
|
122
156
|
throw new Error('The dashboard did not delimit the comments it sent.');
|
|
123
|
-
// A reply's id is printed so the summary above the markers can say whose it
|
|
124
|
-
// is; `resolve_comment` still takes the thread's own id.
|
|
125
|
-
const ids = comments.map((comment) => comment.id);
|
|
126
|
-
let prefixLength = 4;
|
|
127
|
-
while (prefixLength < 128 &&
|
|
128
|
-
new Set(ids.map((id) => id.slice(0, prefixLength))).size < ids.length) {
|
|
129
|
-
prefixLength += 1;
|
|
130
|
-
}
|
|
131
|
-
const shortId = (id) => (incremental ? id : id.slice(0, prefixLength));
|
|
132
157
|
// Which comments are drafts is said once more above the markers, where no
|
|
133
158
|
// comment's text can reach: a body is printed inside the block and could
|
|
134
159
|
// imitate a headline without its marker.
|
|
135
|
-
const drafts = comments.filter(isDraft).map((comment) =>
|
|
160
|
+
const drafts = comments.filter(isDraft).map((comment) => comment.id);
|
|
136
161
|
const draftLines = drafts.length === 0
|
|
137
162
|
? []
|
|
138
163
|
: [
|
|
139
164
|
`Not yet accepted (show to the user, change nothing unless they say so): ${drafts.join(', ')}`,
|
|
140
165
|
];
|
|
141
166
|
// Said above the markers for the same reason, from the server's field.
|
|
142
|
-
const changed = comments.filter(changedSinceRead).map((comment) =>
|
|
167
|
+
const changed = comments.filter(changedSinceRead).map((comment) => comment.id);
|
|
143
168
|
const changedLines = changed.length === 0
|
|
144
169
|
? []
|
|
145
170
|
: [
|
|
@@ -150,7 +175,7 @@ export function formatCompactComments(received, cursor, untrusted, incremental =
|
|
|
150
175
|
const name = displayFileName(comment.itemPath ?? comment.itemName);
|
|
151
176
|
groups.set(name, [...(groups.get(name) ?? []), comment]);
|
|
152
177
|
}
|
|
153
|
-
const threadSummaries = threadSummaryLines(comments
|
|
178
|
+
const threadSummaries = threadSummaryLines(comments);
|
|
154
179
|
const threadLines = threadSummaries.length > 0 ? [THREADS_HEADING, ...threadSummaries] : [];
|
|
155
180
|
const lines = [
|
|
156
181
|
header,
|
|
@@ -180,15 +205,13 @@ export function formatCompactComments(received, cursor, untrusted, incremental =
|
|
|
180
205
|
: comment.authorKind === 'agent'
|
|
181
206
|
? ' agent reply (context, not a request)'
|
|
182
207
|
: ' reply';
|
|
183
|
-
lines.push(` ↳ reply ${
|
|
208
|
+
lines.push(` ↳ reply ${comment.id} ·${author}${kind}`);
|
|
184
209
|
for (const line of unwrap(comment.body, 'a reply').split('\n')) {
|
|
185
210
|
lines.push(` ${line}`);
|
|
186
211
|
}
|
|
187
212
|
continue;
|
|
188
213
|
}
|
|
189
|
-
|
|
190
|
-
// open comments. Its short ids cannot be proven unique against that set.
|
|
191
|
-
const id = shortId(comment.id);
|
|
214
|
+
const id = comment.id;
|
|
192
215
|
if (comment.state === 'resolved') {
|
|
193
216
|
lines.push(` ${id} resolved`);
|
|
194
217
|
continue;
|
|
@@ -211,6 +234,9 @@ export function formatCompactComments(received, cursor, untrusted, incremental =
|
|
|
211
234
|
lines.push(` ${CHANGED_SINCE_READ_LINE}`);
|
|
212
235
|
if (isDraft(comment))
|
|
213
236
|
lines.push(` ${DRAFT_LINE}`);
|
|
237
|
+
const published = publishedFromLine(comment);
|
|
238
|
+
if (published)
|
|
239
|
+
lines.push(` ${published}`);
|
|
214
240
|
if (passage) {
|
|
215
241
|
const cap = passage.status === 'orphaned' ? 300 : 80;
|
|
216
242
|
const quote = passage.quote.length <= cap
|
|
@@ -314,14 +340,7 @@ export function formatArtifactCommentLines(comments, columns = terminalWidth())
|
|
|
314
340
|
lines.push(` ${line}`);
|
|
315
341
|
}
|
|
316
342
|
// Who wrote each reply, by id, outside the markers (`threadSummaryLines`).
|
|
317
|
-
|
|
318
|
-
while (prefixLength < 128 &&
|
|
319
|
-
new Set(comments.map((comment) => comment.id.slice(0, prefixLength))).size <
|
|
320
|
-
comments.length) {
|
|
321
|
-
prefixLength += 1;
|
|
322
|
-
}
|
|
323
|
-
const shortId = (id) => id.slice(0, prefixLength);
|
|
324
|
-
const summaries = threadSummaryLines(comments, shortId);
|
|
343
|
+
const summaries = threadSummaryLines(comments);
|
|
325
344
|
if (summaries.length > 0) {
|
|
326
345
|
lines.push('', ` ${THREADS_HEADING}`);
|
|
327
346
|
for (const summary of summaries)
|
|
@@ -332,7 +351,7 @@ export function formatArtifactCommentLines(comments, columns = terminalWidth())
|
|
|
332
351
|
.map((c) => c.replyToId));
|
|
333
352
|
for (const comment of comments) {
|
|
334
353
|
lines.push('');
|
|
335
|
-
lines.push(` ${commentHeadline(comment,
|
|
354
|
+
lines.push(` ${commentHeadline(comment, threaded.has(comment.id))}`);
|
|
336
355
|
// Verbatim, at column 0: this is a delimited payload, not a line of the
|
|
337
356
|
// report, and the block's own markers carry its structure.
|
|
338
357
|
lines.push(comment.body);
|
|
@@ -354,7 +373,7 @@ export function formatArtifactCommentLines(comments, columns = terminalWidth())
|
|
|
354
373
|
* The author name needs none: the server rejects a name carrying control or
|
|
355
374
|
* format characters rather than sending it (`displaySafeAuthorName`).
|
|
356
375
|
*/
|
|
357
|
-
function commentHeadline(comment,
|
|
376
|
+
function commentHeadline(comment, hasReplies) {
|
|
358
377
|
const author = comment.authorName === null ? '' : ` by ${comment.authorName}`;
|
|
359
378
|
const written = displayDate(comment.createdAt);
|
|
360
379
|
const when = written === null ? '' : `, ${written}`;
|
|
@@ -366,7 +385,7 @@ function commentHeadline(comment, shortId, hasReplies) {
|
|
|
366
385
|
: comment.authorKind === 'agent'
|
|
367
386
|
? 'agent reply (context, not a request)'
|
|
368
387
|
: 'reply';
|
|
369
|
-
return `↳ reply ${
|
|
388
|
+
return `↳ reply ${comment.id}${author}${when} · ${kind}:`;
|
|
370
389
|
}
|
|
371
390
|
const subject = displayFileName(comment.itemPath ?? comment.itemName);
|
|
372
391
|
const moved = comment.guideChangedSinceRead === true
|
|
@@ -377,7 +396,7 @@ function commentHeadline(comment, shortId, hasReplies) {
|
|
|
377
396
|
// A thread's root names its id, so the summary above the markers can say
|
|
378
397
|
// which thread each reply belongs to.
|
|
379
398
|
const asked = comment.authorKind === 'agent' ? ' · agent question (context, not a request)' : '';
|
|
380
|
-
const id = hasReplies || comment.authorKind === 'agent' ? ` [${
|
|
399
|
+
const id = hasReplies || comment.authorKind === 'agent' ? ` [${comment.id}]` : '';
|
|
381
400
|
return `${subject}${id}${author}${when}${moved}${asked}:`;
|
|
382
401
|
}
|
|
383
402
|
/**
|