@pleaseai/ask 0.1.0 → 0.2.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/dist/agents.d.ts +2 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +73 -0
- package/dist/agents.js.map +1 -0
- package/dist/concurrency.d.ts +12 -0
- package/dist/concurrency.d.ts.map +1 -0
- package/dist/concurrency.js +33 -0
- package/dist/concurrency.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/ignore-files.d.ts +59 -0
- package/dist/ignore-files.d.ts.map +1 -0
- package/dist/ignore-files.js +205 -0
- package/dist/ignore-files.js.map +1 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +485 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +55 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +159 -0
- package/dist/io.js.map +1 -0
- package/dist/manifest/index.d.ts +26 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +25 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/npm.d.ts +18 -0
- package/dist/manifest/npm.d.ts.map +1 -0
- package/dist/manifest/npm.js +155 -0
- package/dist/manifest/npm.js.map +1 -0
- package/dist/markers.d.ts +34 -0
- package/dist/markers.d.ts.map +1 -0
- package/dist/markers.js +82 -0
- package/dist/markers.js.map +1 -0
- package/dist/migrate-legacy.d.ts +24 -0
- package/dist/migrate-legacy.d.ts.map +1 -0
- package/dist/migrate-legacy.js +85 -0
- package/dist/migrate-legacy.js.map +1 -0
- package/dist/registry.d.ts +71 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +201 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolvers/index.d.ts +32 -0
- package/dist/resolvers/index.d.ts.map +1 -0
- package/dist/resolvers/index.js +17 -0
- package/dist/resolvers/index.js.map +1 -0
- package/dist/resolvers/maven.d.ts +33 -0
- package/dist/resolvers/maven.d.ts.map +1 -0
- package/dist/resolvers/maven.js +187 -0
- package/dist/resolvers/maven.js.map +1 -0
- package/dist/resolvers/npm.d.ts +13 -0
- package/dist/resolvers/npm.d.ts.map +1 -0
- package/dist/resolvers/npm.js +67 -0
- package/dist/resolvers/npm.js.map +1 -0
- package/dist/resolvers/pub.d.ts +13 -0
- package/dist/resolvers/pub.d.ts.map +1 -0
- package/dist/resolvers/pub.js +50 -0
- package/dist/resolvers/pub.js.map +1 -0
- package/dist/resolvers/pypi.d.ts +12 -0
- package/dist/resolvers/pypi.d.ts.map +1 -0
- package/dist/resolvers/pypi.js +60 -0
- package/dist/resolvers/pypi.js.map +1 -0
- package/dist/resolvers/utils.d.ts +15 -0
- package/dist/resolvers/utils.d.ts.map +1 -0
- package/dist/resolvers/utils.js +26 -0
- package/dist/resolvers/utils.js.map +1 -0
- package/dist/schemas.d.ts +2 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +2 -0
- package/dist/schemas.js.map +1 -0
- package/dist/skill.d.ts +4 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +53 -0
- package/dist/skill.js.map +1 -0
- package/dist/sources/github.d.ts +14 -0
- package/dist/sources/github.d.ts.map +1 -0
- package/dist/sources/github.js +114 -0
- package/dist/sources/github.js.map +1 -0
- package/dist/sources/index.d.ts +41 -0
- package/dist/sources/index.d.ts.map +1 -0
- package/dist/sources/index.js +14 -0
- package/dist/sources/index.js.map +1 -0
- package/dist/sources/llms-txt.d.ts +5 -0
- package/dist/sources/llms-txt.d.ts.map +1 -0
- package/dist/sources/llms-txt.js +33 -0
- package/dist/sources/llms-txt.js.map +1 -0
- package/dist/sources/npm.d.ts +14 -0
- package/dist/sources/npm.d.ts.map +1 -0
- package/dist/sources/npm.js +113 -0
- package/dist/sources/npm.js.map +1 -0
- package/dist/sources/web.d.ts +13 -0
- package/dist/sources/web.d.ts.map +1 -0
- package/dist/sources/web.js +143 -0
- package/dist/sources/web.js.map +1 -0
- package/dist/storage.d.ts +11 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +76 -0
- package/dist/storage.js.map +1 -0
- package/package.json +9 -8
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAOA,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAwF3D"}
|
package/dist/agents.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { getLibraryDocsDir, listDocs } from './storage.js';
|
|
4
|
+
const BEGIN_MARKER = '<!-- BEGIN:ask-docs-auto-generated -->';
|
|
5
|
+
const END_MARKER = '<!-- END:ask-docs-auto-generated -->';
|
|
6
|
+
export function generateAgentsMd(projectDir) {
|
|
7
|
+
const docs = listDocs(projectDir);
|
|
8
|
+
if (docs.length === 0)
|
|
9
|
+
return '';
|
|
10
|
+
const sections = docs.map(({ name, version }) => {
|
|
11
|
+
const docsRelPath = path.relative(projectDir, getLibraryDocsDir(projectDir, name, version));
|
|
12
|
+
const major = version.split('.')[0];
|
|
13
|
+
return `## ${name} v${version}
|
|
14
|
+
|
|
15
|
+
> **WARNING:** This version may differ from your training data.
|
|
16
|
+
> Read the docs in \`${docsRelPath}/\` before writing any ${name}-related code.
|
|
17
|
+
> Heed deprecation notices and breaking changes.
|
|
18
|
+
|
|
19
|
+
- **Version**: \`${version}\` — use \`"^${major}"\` in package.json (NOT older major versions)
|
|
20
|
+
- Documentation: \`${docsRelPath}/\`
|
|
21
|
+
- Index: \`${docsRelPath}/INDEX.md\``;
|
|
22
|
+
});
|
|
23
|
+
const generatedBlock = `${BEGIN_MARKER}
|
|
24
|
+
# Documentation References
|
|
25
|
+
|
|
26
|
+
The libraries in this project may have APIs and patterns that differ from your training data.
|
|
27
|
+
**Always read the relevant documentation before writing code.**
|
|
28
|
+
|
|
29
|
+
## .ask/docs/ — Vendored Documentation
|
|
30
|
+
|
|
31
|
+
\`.ask/docs/\` contains third-party library documentation downloaded by ASK.
|
|
32
|
+
Treat it as **read-only**: AI context should reference these files, but they are
|
|
33
|
+
**not** subject to modification, lint, format, or code review. Updates are
|
|
34
|
+
performed via \`ask docs sync\`.
|
|
35
|
+
|
|
36
|
+
${sections.join('\n\n')}
|
|
37
|
+
${END_MARKER}`;
|
|
38
|
+
// Read existing AGENTS.md and update or create
|
|
39
|
+
const agentsPath = path.join(projectDir, 'AGENTS.md');
|
|
40
|
+
if (fs.existsSync(agentsPath)) {
|
|
41
|
+
const existing = fs.readFileSync(agentsPath, 'utf-8');
|
|
42
|
+
const beginIdx = existing.indexOf(BEGIN_MARKER);
|
|
43
|
+
const endIdx = existing.indexOf(END_MARKER);
|
|
44
|
+
if (beginIdx !== -1 && endIdx !== -1) {
|
|
45
|
+
// Replace existing auto-generated block
|
|
46
|
+
const updated = existing.substring(0, beginIdx)
|
|
47
|
+
+ generatedBlock
|
|
48
|
+
+ existing.substring(endIdx + END_MARKER.length);
|
|
49
|
+
fs.writeFileSync(agentsPath, updated, 'utf-8');
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Append to existing file
|
|
53
|
+
fs.writeFileSync(agentsPath, `${existing.trimEnd()}\n\n${generatedBlock}\n`, 'utf-8');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
fs.writeFileSync(agentsPath, `${generatedBlock}\n`, 'utf-8');
|
|
58
|
+
}
|
|
59
|
+
// Also create/update CLAUDE.md to reference AGENTS.md
|
|
60
|
+
const claudeMdPath = path.join(projectDir, 'CLAUDE.md');
|
|
61
|
+
const claudeRef = '@AGENTS.md';
|
|
62
|
+
if (fs.existsSync(claudeMdPath)) {
|
|
63
|
+
const claudeContent = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
64
|
+
if (!claudeContent.includes(claudeRef)) {
|
|
65
|
+
fs.writeFileSync(claudeMdPath, `${claudeContent.trimEnd()}\n${claudeRef}\n`, 'utf-8');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
fs.writeFileSync(claudeMdPath, `${claudeRef}\n`, 'utf-8');
|
|
70
|
+
}
|
|
71
|
+
return agentsPath;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE1D,MAAM,YAAY,GAAG,wCAAwC,CAAA;AAC7D,MAAM,UAAU,GAAG,sCAAsC,CAAA;AAEzD,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,MAAM,IAAI,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;IAEjC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QACnB,OAAO,EAAE,CAAA;IAEX,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAC/B,UAAU,EACV,iBAAiB,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAC7C,CAAA;QAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAEnC,OAAO,MAAM,IAAI,KAAK,OAAO;;;uBAGV,WAAW,0BAA0B,IAAI;;;mBAG7C,OAAO,gBAAgB,KAAK;qBAC1B,WAAW;aACnB,WA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IACvD,MAAM,SAAS,GAAG,YAAY,CAAA;IAC9B,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAChC,MAAM,aAAa,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAC5D,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACvC,EAAE,CAAC,aAAa,CACd,YAAY,EACZ,GAAG,aAAa,CAAC,OAAO,EAAE,KAAK,SAAS,IAAI,EAC5C,OAAO,CACR,CAAA;QACH,CAAC;IACH,CAAC;SACI,CAAC;QACJ,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,GAAG,SAAS,IAAI,EAAE,OAAO,CAAC,CAAA;IAC3D,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run an async function over a list of items with bounded concurrency.
|
|
3
|
+
*
|
|
4
|
+
* - Preserves input order in the result array (result[i] corresponds to items[i]).
|
|
5
|
+
* - Each `fn` invocation is independent. If `fn` rejects, that rejection
|
|
6
|
+
* propagates — callers that need catch-and-continue semantics MUST wrap `fn`
|
|
7
|
+
* to convert errors into a result variant.
|
|
8
|
+
* - `limit <= 0` is treated as unbounded (effectively `Promise.all`).
|
|
9
|
+
* - Empty input returns an empty array immediately without starting workers.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runWithConcurrency<T, R>(items: readonly T[], limit: number, fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
|
|
12
|
+
//# sourceMappingURL=concurrency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.d.ts","sourceRoot":"","sources":["../src/concurrency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAC3C,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,CAAC,EAAE,CAAC,CAqBd"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run an async function over a list of items with bounded concurrency.
|
|
3
|
+
*
|
|
4
|
+
* - Preserves input order in the result array (result[i] corresponds to items[i]).
|
|
5
|
+
* - Each `fn` invocation is independent. If `fn` rejects, that rejection
|
|
6
|
+
* propagates — callers that need catch-and-continue semantics MUST wrap `fn`
|
|
7
|
+
* to convert errors into a result variant.
|
|
8
|
+
* - `limit <= 0` is treated as unbounded (effectively `Promise.all`).
|
|
9
|
+
* - Empty input returns an empty array immediately without starting workers.
|
|
10
|
+
*/
|
|
11
|
+
export async function runWithConcurrency(items, limit, fn) {
|
|
12
|
+
const results = Array.from({ length: items.length });
|
|
13
|
+
if (items.length === 0) {
|
|
14
|
+
return results;
|
|
15
|
+
}
|
|
16
|
+
const effectiveLimit = limit <= 0 ? items.length : Math.min(limit, items.length);
|
|
17
|
+
let next = 0;
|
|
18
|
+
async function worker() {
|
|
19
|
+
while (true) {
|
|
20
|
+
const i = next++;
|
|
21
|
+
if (i >= items.length)
|
|
22
|
+
return;
|
|
23
|
+
results[i] = await fn(items[i], i);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const workers = [];
|
|
27
|
+
for (let i = 0; i < effectiveLimit; i++) {
|
|
28
|
+
workers.push(worker());
|
|
29
|
+
}
|
|
30
|
+
await Promise.all(workers);
|
|
31
|
+
return results;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=concurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.js","sourceRoot":"","sources":["../src/concurrency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAmB,EACnB,KAAa,EACb,EAA0C;IAE1C,MAAM,OAAO,GAAQ,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACzD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,MAAM,cAAc,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAChF,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,KAAK,UAAU,MAAM;QACnB,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,CAAC,GAAG,IAAI,EAAE,CAAA;YAChB,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM;gBACnB,OAAM;YACR,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACpC,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAoB,EAAE,CAAA;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IACxB,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC1B,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Config } from './schemas.js';
|
|
2
|
+
import type { SourceConfig } from './sources/index.js';
|
|
3
|
+
export type AskConfig = Config;
|
|
4
|
+
export declare function loadConfig(projectDir: string): AskConfig;
|
|
5
|
+
export declare function saveConfig(projectDir: string, config: AskConfig): void;
|
|
6
|
+
export declare function addDocEntry(projectDir: string, entry: SourceConfig): AskConfig;
|
|
7
|
+
export declare function removeDocEntry(projectDir: string, name: string, version?: string): AskConfig;
|
|
8
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGtD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAExD;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAEtE;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,YAAY,GAClB,SAAS,CAaX;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,GACf,SAAS,CAOX"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readConfig, writeConfig } from './io.js';
|
|
2
|
+
export function loadConfig(projectDir) {
|
|
3
|
+
return readConfig(projectDir);
|
|
4
|
+
}
|
|
5
|
+
export function saveConfig(projectDir, config) {
|
|
6
|
+
writeConfig(projectDir, config);
|
|
7
|
+
}
|
|
8
|
+
export function addDocEntry(projectDir, entry) {
|
|
9
|
+
const config = loadConfig(projectDir);
|
|
10
|
+
// Replace existing entry for same name (regardless of version — versions
|
|
11
|
+
// change over time and we keep one entry per library)
|
|
12
|
+
const idx = config.docs.findIndex(d => d.name === entry.name);
|
|
13
|
+
if (idx >= 0) {
|
|
14
|
+
config.docs[idx] = entry;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
config.docs.push(entry);
|
|
18
|
+
}
|
|
19
|
+
saveConfig(projectDir, config);
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
22
|
+
export function removeDocEntry(projectDir, name, version) {
|
|
23
|
+
const config = loadConfig(projectDir);
|
|
24
|
+
config.docs = config.docs.filter(d => !(d.name === name && (!version || d.version === version)));
|
|
25
|
+
saveConfig(projectDir, config);
|
|
26
|
+
return config;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAIjD,MAAM,UAAU,UAAU,CAAC,UAAkB;IAC3C,OAAO,UAAU,CAAC,UAAU,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,UAAkB,EAAE,MAAiB;IAC9D,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;AACjC,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,UAAkB,EAClB,KAAmB;IAEnB,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAA;IACrC,yEAAyE;IACzE,sDAAsD;IACtD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAA;IAC7D,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IAC1B,CAAC;SACI,CAAC;QACJ,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IACD,UAAU,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAC9B,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,UAAkB,EAClB,IAAY,EACZ,OAAgB;IAEhB,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAA;IACrC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAC9B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC,CAC/D,CAAA;IACD,UAAU,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAC9B,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored docs ignore-file management.
|
|
3
|
+
*
|
|
4
|
+
* `.ask/docs/` contains third-party documentation downloaded by ASK. It
|
|
5
|
+
* should not be treated as project source: lint/format/code-review tools
|
|
6
|
+
* should skip it, but AI agents must still be able to read it as context.
|
|
7
|
+
*
|
|
8
|
+
* Strategy:
|
|
9
|
+
* A. Write self-contained nested config files inside `.ask/docs/` for
|
|
10
|
+
* tools that support hierarchical config resolution (Git, ESLint flat
|
|
11
|
+
* config, Biome, markdownlint-cli2).
|
|
12
|
+
* B. The "intent notice" for AI review tools lives in `agents.ts`
|
|
13
|
+
* (extended `generateAgentsMd`).
|
|
14
|
+
* C. Patch root files only for tools that do NOT support nested config
|
|
15
|
+
* (Prettier, SonarQube, legacy markdownlint-cli).
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Category A: write nested config files inside `.ask/docs/`.
|
|
19
|
+
*
|
|
20
|
+
* The directory is created if it does not exist, so callers may invoke this
|
|
21
|
+
* before any docs have been saved. Existing files are only rewritten if
|
|
22
|
+
* their contents differ, to keep filesystem mtimes stable and logs terse.
|
|
23
|
+
*
|
|
24
|
+
* Returns the list of files that were created or updated (relative to the
|
|
25
|
+
* project root) so callers can log a summary.
|
|
26
|
+
*/
|
|
27
|
+
export declare function writeNestedConfigs(projectDir: string): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Remove all nested config files written by {@link writeNestedConfigs}.
|
|
30
|
+
*
|
|
31
|
+
* Only files with the exact names we manage are deleted. Other files
|
|
32
|
+
* inside `.ask/docs/` are left alone (including downloaded docs). Returns
|
|
33
|
+
* the list of removed file paths relative to the project root.
|
|
34
|
+
*/
|
|
35
|
+
export declare function removeNestedConfigs(projectDir: string): string[];
|
|
36
|
+
/**
|
|
37
|
+
* Category C: patch root files that do not support nested ignore resolution.
|
|
38
|
+
*
|
|
39
|
+
* Only files that already exist are patched — ASK never creates a root
|
|
40
|
+
* ignore file from scratch, because doing so could imply a tool the user
|
|
41
|
+
* does not actually use.
|
|
42
|
+
*/
|
|
43
|
+
export declare function patchRootIgnores(projectDir: string): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Remove ASK-managed marker blocks from root files patched by
|
|
46
|
+
* {@link patchRootIgnores}. Files themselves are never deleted.
|
|
47
|
+
*/
|
|
48
|
+
export declare function unpatchRootIgnores(projectDir: string): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Top-level orchestrator called from the add/sync/remove commands.
|
|
51
|
+
*
|
|
52
|
+
* - `install` mode: create nested configs and patch detected root files.
|
|
53
|
+
* - `remove` mode: delete nested configs and strip root marker blocks.
|
|
54
|
+
*
|
|
55
|
+
* Respects `manageIgnores` in `.ask/config.json` (default: true). When the
|
|
56
|
+
* flag is explicitly set to false, the function is a no-op.
|
|
57
|
+
*/
|
|
58
|
+
export declare function manageIgnoreFiles(projectDir: string, mode: 'install' | 'remove'): void;
|
|
59
|
+
//# sourceMappingURL=ignore-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignore-files.d.ts","sourceRoot":"","sources":["../src/ignore-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAsFH;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAc/D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAahE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAmB7D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAc/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,SAAS,GAAG,QAAQ,GACzB,IAAI,CA2BN"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vendored docs ignore-file management.
|
|
3
|
+
*
|
|
4
|
+
* `.ask/docs/` contains third-party documentation downloaded by ASK. It
|
|
5
|
+
* should not be treated as project source: lint/format/code-review tools
|
|
6
|
+
* should skip it, but AI agents must still be able to read it as context.
|
|
7
|
+
*
|
|
8
|
+
* Strategy:
|
|
9
|
+
* A. Write self-contained nested config files inside `.ask/docs/` for
|
|
10
|
+
* tools that support hierarchical config resolution (Git, ESLint flat
|
|
11
|
+
* config, Biome, markdownlint-cli2).
|
|
12
|
+
* B. The "intent notice" for AI review tools lives in `agents.ts`
|
|
13
|
+
* (extended `generateAgentsMd`).
|
|
14
|
+
* C. Patch root files only for tools that do NOT support nested config
|
|
15
|
+
* (Prettier, SonarQube, legacy markdownlint-cli).
|
|
16
|
+
*/
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import { consola } from 'consola';
|
|
20
|
+
import { loadConfig } from './config.js';
|
|
21
|
+
import { inject, remove as removeMarker, wrap } from './markers.js';
|
|
22
|
+
import { getDocsDir } from './storage.js';
|
|
23
|
+
/**
|
|
24
|
+
* Local configuration files written inside `.ask/docs/` so that
|
|
25
|
+
* lint/format/review tools with nested-config support automatically skip
|
|
26
|
+
* the directory. Each file has a `name` (relative to `.ask/docs/`) and a
|
|
27
|
+
* `content` template.
|
|
28
|
+
*/
|
|
29
|
+
const NESTED_CONFIGS = [
|
|
30
|
+
{
|
|
31
|
+
name: '.gitattributes',
|
|
32
|
+
content: [
|
|
33
|
+
'# Managed by ASK — marks vendored docs for GitHub Linguist.',
|
|
34
|
+
'* linguist-vendored=true',
|
|
35
|
+
'* linguist-generated=true',
|
|
36
|
+
'',
|
|
37
|
+
].join('\n'),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'eslint.config.mjs',
|
|
41
|
+
content: [
|
|
42
|
+
'// Managed by ASK — vendored docs, excluded from ESLint.',
|
|
43
|
+
'export default [',
|
|
44
|
+
' { ignores: [\'**/*\'] },',
|
|
45
|
+
']',
|
|
46
|
+
'',
|
|
47
|
+
].join('\n'),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'biome.json',
|
|
51
|
+
content: `${JSON.stringify({
|
|
52
|
+
$schema: 'https://biomejs.dev/schemas/2.0.0/schema.json',
|
|
53
|
+
files: { ignore: ['**/*'] },
|
|
54
|
+
}, null, 2)}\n`,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: '.markdownlint-cli2.jsonc',
|
|
58
|
+
content: `${JSON.stringify({ ignores: ['**/*'] }, null, 2)}\n`,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
const ROOT_PATCHES = [
|
|
62
|
+
{
|
|
63
|
+
file: '.prettierignore',
|
|
64
|
+
syntax: 'hash',
|
|
65
|
+
payload: '# Vendored docs — managed by ASK\n.ask/docs/',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
file: 'sonar-project.properties',
|
|
69
|
+
syntax: 'hash',
|
|
70
|
+
payload: '# Vendored docs — managed by ASK\nsonar.exclusions=.ask/docs/**',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
file: '.markdownlintignore',
|
|
74
|
+
syntax: 'hash',
|
|
75
|
+
payload: '# Vendored docs — managed by ASK\n.ask/docs/',
|
|
76
|
+
warn: 'Legacy .markdownlintignore detected. Consider migrating to markdownlint-cli2, which supports nested config inside .ask/docs/ automatically.',
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
/**
|
|
80
|
+
* Category A: write nested config files inside `.ask/docs/`.
|
|
81
|
+
*
|
|
82
|
+
* The directory is created if it does not exist, so callers may invoke this
|
|
83
|
+
* before any docs have been saved. Existing files are only rewritten if
|
|
84
|
+
* their contents differ, to keep filesystem mtimes stable and logs terse.
|
|
85
|
+
*
|
|
86
|
+
* Returns the list of files that were created or updated (relative to the
|
|
87
|
+
* project root) so callers can log a summary.
|
|
88
|
+
*/
|
|
89
|
+
export function writeNestedConfigs(projectDir) {
|
|
90
|
+
const docsDir = getDocsDir(projectDir);
|
|
91
|
+
fs.mkdirSync(docsDir, { recursive: true });
|
|
92
|
+
const written = [];
|
|
93
|
+
for (const { name, content } of NESTED_CONFIGS) {
|
|
94
|
+
const target = path.join(docsDir, name);
|
|
95
|
+
const existing = fs.existsSync(target) ? fs.readFileSync(target, 'utf-8') : null;
|
|
96
|
+
if (existing !== content) {
|
|
97
|
+
fs.writeFileSync(target, content, 'utf-8');
|
|
98
|
+
written.push(path.relative(projectDir, target));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return written;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Remove all nested config files written by {@link writeNestedConfigs}.
|
|
105
|
+
*
|
|
106
|
+
* Only files with the exact names we manage are deleted. Other files
|
|
107
|
+
* inside `.ask/docs/` are left alone (including downloaded docs). Returns
|
|
108
|
+
* the list of removed file paths relative to the project root.
|
|
109
|
+
*/
|
|
110
|
+
export function removeNestedConfigs(projectDir) {
|
|
111
|
+
const docsDir = getDocsDir(projectDir);
|
|
112
|
+
if (!fs.existsSync(docsDir))
|
|
113
|
+
return [];
|
|
114
|
+
const removed = [];
|
|
115
|
+
for (const { name } of NESTED_CONFIGS) {
|
|
116
|
+
const target = path.join(docsDir, name);
|
|
117
|
+
if (fs.existsSync(target)) {
|
|
118
|
+
fs.rmSync(target);
|
|
119
|
+
removed.push(path.relative(projectDir, target));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return removed;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Category C: patch root files that do not support nested ignore resolution.
|
|
126
|
+
*
|
|
127
|
+
* Only files that already exist are patched — ASK never creates a root
|
|
128
|
+
* ignore file from scratch, because doing so could imply a tool the user
|
|
129
|
+
* does not actually use.
|
|
130
|
+
*/
|
|
131
|
+
export function patchRootIgnores(projectDir) {
|
|
132
|
+
const updated = [];
|
|
133
|
+
for (const patch of ROOT_PATCHES) {
|
|
134
|
+
const target = path.join(projectDir, patch.file);
|
|
135
|
+
if (!fs.existsSync(target))
|
|
136
|
+
continue;
|
|
137
|
+
const existing = fs.readFileSync(target, 'utf-8');
|
|
138
|
+
const block = wrap(patch.payload, patch.syntax);
|
|
139
|
+
const next = inject(existing, block, patch.syntax);
|
|
140
|
+
if (next !== existing) {
|
|
141
|
+
fs.writeFileSync(target, next, 'utf-8');
|
|
142
|
+
updated.push(patch.file);
|
|
143
|
+
}
|
|
144
|
+
if (patch.warn) {
|
|
145
|
+
consola.warn(patch.warn);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return updated;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Remove ASK-managed marker blocks from root files patched by
|
|
152
|
+
* {@link patchRootIgnores}. Files themselves are never deleted.
|
|
153
|
+
*/
|
|
154
|
+
export function unpatchRootIgnores(projectDir) {
|
|
155
|
+
const updated = [];
|
|
156
|
+
for (const patch of ROOT_PATCHES) {
|
|
157
|
+
const target = path.join(projectDir, patch.file);
|
|
158
|
+
if (!fs.existsSync(target))
|
|
159
|
+
continue;
|
|
160
|
+
const existing = fs.readFileSync(target, 'utf-8');
|
|
161
|
+
const next = removeMarker(existing, patch.syntax);
|
|
162
|
+
if (next !== existing) {
|
|
163
|
+
fs.writeFileSync(target, next, 'utf-8');
|
|
164
|
+
updated.push(patch.file);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return updated;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Top-level orchestrator called from the add/sync/remove commands.
|
|
171
|
+
*
|
|
172
|
+
* - `install` mode: create nested configs and patch detected root files.
|
|
173
|
+
* - `remove` mode: delete nested configs and strip root marker blocks.
|
|
174
|
+
*
|
|
175
|
+
* Respects `manageIgnores` in `.ask/config.json` (default: true). When the
|
|
176
|
+
* flag is explicitly set to false, the function is a no-op.
|
|
177
|
+
*/
|
|
178
|
+
export function manageIgnoreFiles(projectDir, mode) {
|
|
179
|
+
// `loadConfig` returns a default empty config when `.ask/config.json`
|
|
180
|
+
// does not exist, and throws for corrupt/invalid files. We deliberately
|
|
181
|
+
// do NOT wrap this in a try/catch: callers should hear about a broken
|
|
182
|
+
// config rather than silently proceeding with mutations.
|
|
183
|
+
const config = loadConfig(projectDir);
|
|
184
|
+
if (config.manageIgnores === false) {
|
|
185
|
+
consola.info('Skipping ignore-file management (manageIgnores: false).');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (mode === 'install') {
|
|
189
|
+
const nested = writeNestedConfigs(projectDir);
|
|
190
|
+
const root = patchRootIgnores(projectDir);
|
|
191
|
+
if (nested.length > 0)
|
|
192
|
+
consola.info(`Nested configs written: ${nested.join(', ')}`);
|
|
193
|
+
if (root.length > 0)
|
|
194
|
+
consola.info(`Root ignore files patched: ${root.join(', ')}`);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
const nested = removeNestedConfigs(projectDir);
|
|
198
|
+
const root = unpatchRootIgnores(projectDir);
|
|
199
|
+
if (nested.length > 0)
|
|
200
|
+
consola.info(`Nested configs removed: ${nested.join(', ')}`);
|
|
201
|
+
if (root.length > 0)
|
|
202
|
+
consola.info(`Root ignore marker blocks removed: ${root.join(', ')}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=ignore-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignore-files.js","sourceRoot":"","sources":["../src/ignore-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;GAKG;AACH,MAAM,cAAc,GAA6C;IAC/D;QACE,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE;YACP,6DAA6D;YAC7D,0BAA0B;YAC1B,2BAA2B;YAC3B,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC;KACb;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE;YACP,0DAA0D;YAC1D,kBAAkB;YAClB,4BAA4B;YAC5B,GAAG;YACH,EAAE;SACH,CAAC,IAAI,CAAC,IAAI,CAAC;KACb;IACD;QACE,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CACxB;YACE,OAAO,EAAE,+CAA+C;YACxD,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE;SAC5B,EACD,IAAI,EACJ,CAAC,CACF,IAAI;KACN;IACD;QACE,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CACxB,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,EACrB,IAAI,EACJ,CAAC,CACF,IAAI;KACN;CACF,CAAA;AAaD,MAAM,YA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AAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAA;QAC7C,MAAM,IAAI,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAA;QACzC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,2BAA2B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC9D,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,8BAA8B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACjE,CAAC;SACI,CAAC;QACJ,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAA;QAC9C,MAAM,IAAI,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAA;QAC3C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,2BAA2B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC9D,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,sCAAsC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACzE,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import type { Lock } from './schemas.js';
|
|
3
|
+
import type { SourceConfig } from './sources/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Gate A: reject bare-name specs (`ask docs add next`).
|
|
6
|
+
*
|
|
7
|
+
* Bare names are ambiguous — they give the CLI no ecosystem hint and no
|
|
8
|
+
* explicit source, and silently auto-resolving them (which the old code did)
|
|
9
|
+
* can hand back wrong-looking docs. Instead we force the caller to either use
|
|
10
|
+
* an ecosystem prefix (`npm:next`) or the github shorthand (`owner/repo`).
|
|
11
|
+
*
|
|
12
|
+
* Returns an error message when the spec is ambiguous, or `null` when it is
|
|
13
|
+
* OK to proceed. `hasExplicitSource` lets the caller opt out of the check
|
|
14
|
+
* when `--source` is passed explicitly — an explicit source disambiguates.
|
|
15
|
+
*/
|
|
16
|
+
export declare function checkBareNameGate(input: string, parsedKind: 'github' | 'ecosystem' | 'name', hasExplicitSource: boolean): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Gate B: manifest-based version resolution.
|
|
19
|
+
*
|
|
20
|
+
* When the user writes `npm:next` with no version, consult the project
|
|
21
|
+
* lockfile/manifest and try to use the installed version — this guarantees
|
|
22
|
+
* the downloaded docs match what's actually in the project.
|
|
23
|
+
*
|
|
24
|
+
* Resolution policy:
|
|
25
|
+
* - lockfile exact hit → override version, log provenance
|
|
26
|
+
* - manifest range hit → override version, log provenance (resolver will
|
|
27
|
+
* later normalize the range)
|
|
28
|
+
* - no hit + `--from-manifest` → error (user explicitly required manifest)
|
|
29
|
+
* - no hit otherwise → leave version as `'latest'` and fall through
|
|
30
|
+
* to the existing resolver pipeline
|
|
31
|
+
*
|
|
32
|
+
* Returns `{ kind: 'ok', version? }` with the override version (or undefined
|
|
33
|
+
* if no override applied) or `{ kind: 'error', message }` when `--from-manifest`
|
|
34
|
+
* required a hit but we got none.
|
|
35
|
+
*
|
|
36
|
+
* The `readerFactory` argument is injectable so tests can supply mock readers
|
|
37
|
+
* without creating real lockfiles on disk.
|
|
38
|
+
*/
|
|
39
|
+
export type ManifestGateResult = {
|
|
40
|
+
kind: 'ok';
|
|
41
|
+
version?: string;
|
|
42
|
+
source?: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'error';
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
export declare function runManifestGate(ecosystem: string, name: string, version: string, projectDir: string, opts: {
|
|
48
|
+
noManifest: boolean;
|
|
49
|
+
fromManifest: boolean;
|
|
50
|
+
}, readerFactory?: (eco: string) => {
|
|
51
|
+
readInstalledVersion: (n: string, d: string) => {
|
|
52
|
+
version: string;
|
|
53
|
+
source: string;
|
|
54
|
+
exact: boolean;
|
|
55
|
+
} | null;
|
|
56
|
+
} | undefined): ManifestGateResult;
|
|
57
|
+
type SyncStatus = 'drifted' | 'unchanged' | 'failed';
|
|
58
|
+
export interface RunSyncOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Override the per-entry sync function. Used by tests; defaults to the
|
|
61
|
+
* real `syncEntry` which performs network fetches and disk writes.
|
|
62
|
+
*/
|
|
63
|
+
syncEntryFn?: (projectDir: string, entry: SourceConfig, lock: Lock) => Promise<SyncStatus>;
|
|
64
|
+
/**
|
|
65
|
+
* Skip the AGENTS.md regeneration step. Used by tests that don't care
|
|
66
|
+
* about that side effect.
|
|
67
|
+
*/
|
|
68
|
+
skipAgentsMd?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export declare function runSync(projectDir: string, options?: RunSyncOptions): Promise<{
|
|
71
|
+
drifted: number;
|
|
72
|
+
unchanged: number;
|
|
73
|
+
failed: number;
|
|
74
|
+
}>;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,IAAI,EAAa,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EAKV,YAAY,EAEb,MAAM,oBAAoB,CAAA;AAsE3B;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,QAAQ,GAAG,WAAW,GAAG,MAAM,EAC3C,iBAAiB,EAAE,OAAO,GACzB,MAAM,GAAG,IAAI,CAWf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,kBAAkB,GACxB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MA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