@astryxdesign/cli 0.7.6-canary.2d1900c → 0.7.6-canary.2d6154d
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.
|
@@ -31,7 +31,9 @@ export function gatherCandidates(options: {
|
|
|
31
31
|
* folder, for the same `type`, ranks the candidates an earlier search
|
|
32
32
|
* gathered when none of the files that gather read, and none of the folders
|
|
33
33
|
* it listed or probed, changed since (each is checked by its change time and
|
|
34
|
-
* size, so an edited doc in a linked package is seen on the next call).
|
|
34
|
+
* size, so an edited doc in a linked package is seen on the next call). That
|
|
35
|
+
* holds for a gather that is still running too, so searches that start
|
|
36
|
+
* together (a docs site's search right after it starts) share one gather. A
|
|
35
37
|
* long-running caller (a docs site's search, an agent harness) then pays the
|
|
36
38
|
* gather once. A one-shot `astryx search` gathers once, as before.
|
|
37
39
|
* @param {{cwd?: string, type?: string}} options
|
package/api/search/_adapter.mjs
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
import {readFileSync} from 'node:fs';
|
|
10
10
|
import * as path from 'node:path';
|
|
11
11
|
import {requireCoreDir} from '../../foundation/fs/paths.mjs';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
reusedWhileUnchanged,
|
|
14
|
+
unchangedSince,
|
|
15
|
+
} from '../../foundation/fs/read-record.mjs';
|
|
13
16
|
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
14
17
|
import {coreDirOrThrow} from '../error.mjs';
|
|
15
18
|
import {CORELESS_DOMAINS} from './_query.mjs';
|
|
@@ -95,7 +98,7 @@ export async function gatherCandidates(options) {
|
|
|
95
98
|
|
|
96
99
|
/**
|
|
97
100
|
* @typedef {Awaited<ReturnType<typeof gatherCandidates>>} Gathered
|
|
98
|
-
* @type {Map<string, {
|
|
101
|
+
* @type {Map<string, (options?: {fresh?: boolean}) => Promise<Gathered>>}
|
|
99
102
|
*/
|
|
100
103
|
const gathered = new Map();
|
|
101
104
|
|
|
@@ -104,30 +107,27 @@ const gathered = new Map();
|
|
|
104
107
|
* folder, for the same `type`, ranks the candidates an earlier search
|
|
105
108
|
* gathered when none of the files that gather read, and none of the folders
|
|
106
109
|
* it listed or probed, changed since (each is checked by its change time and
|
|
107
|
-
* size, so an edited doc in a linked package is seen on the next call).
|
|
110
|
+
* size, so an edited doc in a linked package is seen on the next call). That
|
|
111
|
+
* holds for a gather that is still running too, so searches that start
|
|
112
|
+
* together (a docs site's search right after it starts) share one gather. A
|
|
108
113
|
* long-running caller (a docs site's search, an agent harness) then pays the
|
|
109
114
|
* gather once. A one-shot `astryx search` gathers once, as before.
|
|
110
115
|
* @param {{cwd?: string, type?: string}} options
|
|
111
116
|
* @returns {Promise<Gathered>}
|
|
112
117
|
*/
|
|
113
|
-
export
|
|
118
|
+
export function gatherCandidatesReused(options) {
|
|
114
119
|
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (gathered.get(key)?.value === value) gathered.delete(key);
|
|
125
|
-
throw error;
|
|
120
|
+
const type = options.type;
|
|
121
|
+
const key = `${cwd}\0${type ?? ''}`;
|
|
122
|
+
let gather = gathered.get(key);
|
|
123
|
+
if (!gather) {
|
|
124
|
+
gather = reusedWhileUnchanged(
|
|
125
|
+
() => gatherCandidates({cwd, type}),
|
|
126
|
+
unchangedSince,
|
|
127
|
+
);
|
|
128
|
+
gathered.set(key, gather);
|
|
126
129
|
}
|
|
127
|
-
|
|
128
|
-
// the gather ran shows as a change on the next call.
|
|
129
|
-
gathered.set(key, {reads: seen, value});
|
|
130
|
-
return value;
|
|
130
|
+
return gather();
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/**
|
|
@@ -38,8 +38,11 @@ export function recordReads<T>(seen: Map<string, string>, fn: () => T): T;
|
|
|
38
38
|
* read counts as read by the operation that asks for it.
|
|
39
39
|
* @template T
|
|
40
40
|
* @param {() => Promise<T>} load
|
|
41
|
+
* @param {(recorded: Map<string, string>) => boolean} [isUnchanged] - Whether
|
|
42
|
+
* recorded paths are unchanged; `unchangedSince` unless a caller passes the
|
|
43
|
+
* one it imports (so a test of that caller can hold the answer).
|
|
41
44
|
* @returns {(options?: {fresh?: boolean}) => Promise<T>}
|
|
42
45
|
*/
|
|
43
|
-
export function reusedWhileUnchanged<T>(load: () => Promise<T>): (options?: {
|
|
46
|
+
export function reusedWhileUnchanged<T>(load: () => Promise<T>, isUnchanged?: (recorded: Map<string, string>) => boolean): (options?: {
|
|
44
47
|
fresh?: boolean;
|
|
45
48
|
}) => Promise<T>;
|
|
@@ -170,19 +170,23 @@ export function recordReads(seen, fn) {
|
|
|
170
170
|
* read counts as read by the operation that asks for it.
|
|
171
171
|
* @template T
|
|
172
172
|
* @param {() => Promise<T>} load
|
|
173
|
+
* @param {(recorded: Map<string, string>) => boolean} [isUnchanged] - Whether
|
|
174
|
+
* recorded paths are unchanged; `unchangedSince` unless a caller passes the
|
|
175
|
+
* one it imports (so a test of that caller can hold the answer).
|
|
173
176
|
* @returns {(options?: {fresh?: boolean}) => Promise<T>}
|
|
174
177
|
*/
|
|
175
|
-
export function reusedWhileUnchanged(load) {
|
|
178
|
+
export function reusedWhileUnchanged(load, isUnchanged = unchangedSince) {
|
|
176
179
|
/** @type {{reads: Map<string, string>, value: Promise<T>} | undefined} */
|
|
177
180
|
let last;
|
|
178
181
|
return ({fresh = false} = {}) => {
|
|
179
|
-
if (!fresh && last &&
|
|
182
|
+
if (!fresh && last && isUnchanged(last.reads)) {
|
|
180
183
|
const {reads: recorded, value} = last;
|
|
181
184
|
return value.then(result => {
|
|
182
185
|
const runs = reads.getStore();
|
|
183
|
-
if (runs)
|
|
184
|
-
for (const
|
|
185
|
-
|
|
186
|
+
if (runs)
|
|
187
|
+
for (const [file, state] of recorded) {
|
|
188
|
+
for (const seen of runs) if (!seen.has(file)) seen.set(file, state);
|
|
189
|
+
}
|
|
186
190
|
return result;
|
|
187
191
|
});
|
|
188
192
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.6-canary.
|
|
3
|
+
"version": "0.7.6-canary.2d6154d",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -124,10 +124,10 @@
|
|
|
124
124
|
"zod": "^4.4.3"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@astryxdesign/charts": "0.7.6-canary.
|
|
128
|
-
"@astryxdesign/core": "0.7.6-canary.
|
|
129
|
-
"@astryxdesign/lab": "0.7.6-canary.
|
|
130
|
-
"@astryxdesign/theme-neutral": "0.7.6-canary.
|
|
127
|
+
"@astryxdesign/charts": "0.7.6-canary.2d6154d",
|
|
128
|
+
"@astryxdesign/core": "0.7.6-canary.2d6154d",
|
|
129
|
+
"@astryxdesign/lab": "0.7.6-canary.2d6154d",
|
|
130
|
+
"@astryxdesign/theme-neutral": "0.7.6-canary.2d6154d"
|
|
131
131
|
},
|
|
132
132
|
"peerDependenciesMeta": {
|
|
133
133
|
"@astryxdesign/charts": {
|
|
@@ -144,10 +144,10 @@
|
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
146
|
"devDependencies": {
|
|
147
|
-
"@astryxdesign/charts": "0.7.6-canary.
|
|
148
|
-
"@astryxdesign/core": "0.7.6-canary.
|
|
149
|
-
"@astryxdesign/lab": "0.7.6-canary.
|
|
150
|
-
"@astryxdesign/theme-neutral": "0.7.6-canary.
|
|
147
|
+
"@astryxdesign/charts": "0.7.6-canary.2d6154d",
|
|
148
|
+
"@astryxdesign/core": "0.7.6-canary.2d6154d",
|
|
149
|
+
"@astryxdesign/lab": "0.7.6-canary.2d6154d",
|
|
150
|
+
"@astryxdesign/theme-neutral": "0.7.6-canary.2d6154d",
|
|
151
151
|
"@heroicons/react": "^2.2.0",
|
|
152
152
|
"@stylexjs/stylex": "^0.19.0",
|
|
153
153
|
"@types/babel__core": "^7.20.5",
|