@context-forge/core 0.13.2 → 0.15.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/config/ConfigKeys.d.ts.map +1 -1
- package/dist/config/ConfigKeys.js +5 -2
- package/dist/config/ConfigKeys.js.map +1 -1
- package/dist/guides/GuideDetector.d.ts +20 -2
- package/dist/guides/GuideDetector.d.ts.map +1 -1
- package/dist/guides/GuideDetector.js +41 -7
- package/dist/guides/GuideDetector.js.map +1 -1
- package/dist/guides/GuideManager.d.ts +58 -5
- package/dist/guides/GuideManager.d.ts.map +1 -1
- package/dist/guides/GuideManager.js +126 -29
- package/dist/guides/GuideManager.js.map +1 -1
- package/dist/guides/branchGuard.d.ts.map +1 -1
- package/dist/guides/branchGuard.js +32 -1
- package/dist/guides/branchGuard.js.map +1 -1
- package/dist/guides/gitExec.d.ts +13 -1
- package/dist/guides/gitExec.d.ts.map +1 -1
- package/dist/guides/gitExec.js +19 -3
- package/dist/guides/gitExec.js.map +1 -1
- package/dist/guides/index.d.ts +1 -1
- package/dist/guides/index.d.ts.map +1 -1
- package/dist/guides/index.js +1 -1
- package/dist/guides/index.js.map +1 -1
- package/dist/guides/strategies/SubmoduleStrategy.d.ts +17 -0
- package/dist/guides/strategies/SubmoduleStrategy.d.ts.map +1 -1
- package/dist/guides/strategies/SubmoduleStrategy.js +21 -2
- package/dist/guides/strategies/SubmoduleStrategy.js.map +1 -1
- package/dist/guides/strategies/TarballStrategy.d.ts +20 -1
- package/dist/guides/strategies/TarballStrategy.d.ts.map +1 -1
- package/dist/guides/strategies/TarballStrategy.js +87 -29
- package/dist/guides/strategies/TarballStrategy.js.map +1 -1
- package/dist/guides/types.d.ts +82 -2
- package/dist/guides/types.d.ts.map +1 -1
- package/dist/guides/types.js +76 -0
- package/dist/guides/types.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/introspection/parsers/documentDetector.d.ts.map +1 -1
- package/dist/introspection/parsers/documentDetector.js +28 -2
- package/dist/introspection/parsers/documentDetector.js.map +1 -1
- package/dist/introspection/reviewGate.js +1 -1
- package/dist/introspection/reviewGate.js.map +1 -1
- package/dist/schema/resolveFileByIndex.d.ts.map +1 -1
- package/dist/schema/resolveFileByIndex.js +9 -2
- package/dist/schema/resolveFileByIndex.js.map +1 -1
- package/package.json +4 -3
package/dist/guides/gitExec.d.ts
CHANGED
|
@@ -10,12 +10,24 @@ export interface GitExecResult {
|
|
|
10
10
|
export declare const GUIDE_OFFLINE_REMEDIATION: string;
|
|
11
11
|
/** Append remediation guidance when a message looks like a network/DNS failure. */
|
|
12
12
|
export declare function withNetworkErrorHint(message: string): string;
|
|
13
|
+
export interface GitExecOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Kill the command after this many milliseconds. Omit for no bound.
|
|
16
|
+
*
|
|
17
|
+
* Only automatic operations inside a read command set this: a credential
|
|
18
|
+
* prompt is already prevented by GIT_NONINTERACTIVE_ENV, but a proxy that
|
|
19
|
+
* accepts a connection and never answers would otherwise block for the OS
|
|
20
|
+
* TCP timeout. User-initiated install and update stay unbounded (D10).
|
|
21
|
+
*/
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}
|
|
13
24
|
/**
|
|
14
25
|
* Execute a git command safely using execFile (no shell injection).
|
|
15
26
|
* @param args - arguments to pass to git (e.g., ['clone', url, dir])
|
|
16
27
|
* @param cwd - working directory for the command
|
|
28
|
+
* @param opts - optional execution bounds
|
|
17
29
|
*/
|
|
18
|
-
export declare function gitExec(args: string[], cwd: string): Promise<GitExecResult>;
|
|
30
|
+
export declare function gitExec(args: string[], cwd: string, opts?: GitExecOptions): Promise<GitExecResult>;
|
|
19
31
|
/** Check whether git is available on the system */
|
|
20
32
|
export declare function isGitAvailable(): Promise<boolean>;
|
|
21
33
|
/** Check whether a directory is inside a git repository */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitExec.d.ts","sourceRoot":"","sources":["../../src/guides/gitExec.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"gitExec.d.ts","sourceRoot":"","sources":["../../src/guides/gitExec.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AA4BD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,QAE4B,CAAC;AAEnE,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ5D;AAED,MAAM,WAAW,cAAc;IAC7B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,aAAa,CAAC,CA+BxB;AAED,mDAAmD;AACnD,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAOvD;AAED,2DAA2D;AAC3D,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO7D"}
|
package/dist/guides/gitExec.js
CHANGED
|
@@ -13,6 +13,9 @@ const NETWORK_ERROR_PATTERNS = [
|
|
|
13
13
|
/could not resolve host/i,
|
|
14
14
|
/could not connect to/i,
|
|
15
15
|
/connection timed out/i,
|
|
16
|
+
// Our own timeout message (see GitExecOptions.timeoutMs). The existing
|
|
17
|
+
// 'connection timed out' pattern is git's wording and does not match it.
|
|
18
|
+
/timed out after \d+s/i,
|
|
16
19
|
/network is unreachable/i,
|
|
17
20
|
/ssl certificate problem/i,
|
|
18
21
|
/failed to connect/i,
|
|
@@ -39,12 +42,25 @@ export function withNetworkErrorHint(message) {
|
|
|
39
42
|
* Execute a git command safely using execFile (no shell injection).
|
|
40
43
|
* @param args - arguments to pass to git (e.g., ['clone', url, dir])
|
|
41
44
|
* @param cwd - working directory for the command
|
|
45
|
+
* @param opts - optional execution bounds
|
|
42
46
|
*/
|
|
43
|
-
export function gitExec(args, cwd) {
|
|
47
|
+
export function gitExec(args, cwd, opts) {
|
|
44
48
|
return new Promise((resolve, reject) => {
|
|
45
|
-
|
|
49
|
+
const timeoutMs = opts?.timeoutMs;
|
|
50
|
+
execFile('git', args, {
|
|
51
|
+
cwd,
|
|
52
|
+
env: { ...process.env, ...GIT_NONINTERACTIVE_ENV },
|
|
53
|
+
...(timeoutMs ? { timeout: timeoutMs, killSignal: 'SIGTERM' } : {}),
|
|
54
|
+
}, (error, stdout, stderr) => {
|
|
46
55
|
if (error) {
|
|
47
|
-
|
|
56
|
+
// execFile reports a timeout kill via `killed`; surface it as a
|
|
57
|
+
// timeout so withNetworkErrorHint's /timed out/i pattern appends the
|
|
58
|
+
// offline remediation text.
|
|
59
|
+
const killedByTimeout = timeoutMs !== undefined &&
|
|
60
|
+
error.killed === true;
|
|
61
|
+
const detail = killedByTimeout
|
|
62
|
+
? `timed out after ${Math.round(timeoutMs / 1000)}s`
|
|
63
|
+
: stderr.trim() || error.message;
|
|
48
64
|
reject(new Error(withNetworkErrorHint(`git ${redactCredentials(args)} failed in ${cwd}: ${detail}`)));
|
|
49
65
|
return;
|
|
50
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitExec.js","sourceRoot":"","sources":["../../src/guides/gitExec.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOzC,oFAAoF;AACpF,kFAAkF;AAClF,mFAAmF;AACnF,MAAM,sBAAsB,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,CAA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|
export { GuideDetector } from './GuideDetector.js';
|
|
3
|
-
export { type GuideInfo, type GuideMethod, type InstallResult, type UpdateResult, type DetectionResult, type InstallStrategy, DEFAULT_SOURCE_GIT, DEFAULT_SOURCE_API, GUIDE_RELATIVE_PATH, VERSION_MARKER_FILE, } from './types.js';
|
|
3
|
+
export { type GuideInfo, type GuideMethod, type InstallResult, type UpdateResult, type DetectionResult, type InstallStrategy, type SubmoduleCheckoutState, type EnsureCheckoutResult, CHECKOUT_STATE_LABELS, GUIDE_INIT_TIMEOUT_MS, GUIDE_MANAGED_NOTICE, GUIDE_METHODS, GUIDE_METHOD_DEPRECATED_ALIASES, normalizeGuideMethod, isDeprecatedGuideMethodAlias, DEFAULT_SOURCE_GIT, DEFAULT_SOURCE_API, GUIDE_RELATIVE_PATH, VERSION_MARKER_FILE, GUIDE_STRATEGIES, guideMethodDeprecationMessage, } from './types.js';
|
|
4
4
|
export { GUIDE_OFFLINE_REMEDIATION } from './gitExec.js';
|
|
5
5
|
export { type BranchGuardVerdict, evaluateBranchGuard, BranchGuardBlockedError, BranchGuardWarnError, } from './branchGuard.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guides/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guides/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,+BAA+B,EAC/B,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EACL,KAAK,kBAAkB,EACvB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
|
package/dist/guides/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Guide management — public exports
|
|
2
2
|
export { GuideManager } from './GuideManager.js';
|
|
3
3
|
export { GuideDetector } from './GuideDetector.js';
|
|
4
|
-
export { DEFAULT_SOURCE_GIT, DEFAULT_SOURCE_API, GUIDE_RELATIVE_PATH, VERSION_MARKER_FILE, } from './types.js';
|
|
4
|
+
export { CHECKOUT_STATE_LABELS, GUIDE_INIT_TIMEOUT_MS, GUIDE_MANAGED_NOTICE, GUIDE_METHODS, GUIDE_METHOD_DEPRECATED_ALIASES, normalizeGuideMethod, isDeprecatedGuideMethodAlias, DEFAULT_SOURCE_GIT, DEFAULT_SOURCE_API, GUIDE_RELATIVE_PATH, VERSION_MARKER_FILE, GUIDE_STRATEGIES, guideMethodDeprecationMessage, } from './types.js';
|
|
5
5
|
// gitExec itself stays internal; only the shared remediation text is public (#78).
|
|
6
6
|
export { GUIDE_OFFLINE_REMEDIATION } from './gitExec.js';
|
|
7
7
|
export { evaluateBranchGuard, BranchGuardBlockedError, BranchGuardWarnError, } from './branchGuard.js';
|
package/dist/guides/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guides/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/guides/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EASL,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,+BAA+B,EAC/B,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,YAAY,CAAC;AACpB,mFAAmF;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAEL,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
|
|
@@ -10,5 +10,22 @@ export declare class SubmoduleStrategy implements InstallStrategy {
|
|
|
10
10
|
* where `git submodule update` would only sync to the worktree's own index.
|
|
11
11
|
*/
|
|
12
12
|
sync(worktreePath: string, projectPath: string): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Check out an uninitialized guide submodule at the commit the host repo
|
|
15
|
+
* pins, and report that commit.
|
|
16
|
+
*
|
|
17
|
+
* Only touches the submodule working tree: it runs no `git add` and makes no
|
|
18
|
+
* host commit, so it cannot trip the branch guard. Safe to call when the
|
|
19
|
+
* submodule is already initialized, in which case git does nothing.
|
|
20
|
+
*
|
|
21
|
+
* @param operationPath - repo (or worktree) whose submodule to initialize
|
|
22
|
+
* @param opts.timeoutMs - bound the fetch; callers on a read path set this,
|
|
23
|
+
* install and update leave it unset (D10)
|
|
24
|
+
*/
|
|
25
|
+
init(operationPath: string, opts?: {
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
commit: string;
|
|
29
|
+
}>;
|
|
13
30
|
}
|
|
14
31
|
//# sourceMappingURL=SubmoduleStrategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubmoduleStrategy.d.ts","sourceRoot":"","sources":["../../../src/guides/strategies/SubmoduleStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIjG,qBAAa,iBAAkB,YAAW,eAAe;IACjD,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IA2B/E,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAkCvF,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAsC3E;;;;;OAKG;IACG,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"SubmoduleStrategy.d.ts","sourceRoot":"","sources":["../../../src/guides/strategies/SubmoduleStrategy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAIjG,qBAAa,iBAAkB,YAAW,eAAe;IACjD,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IA2B/E,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAkCvF,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAsC3E;;;;;OAKG;IACG,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBpE;;;;;;;;;;;OAWG;IACG,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAW9F"}
|
|
@@ -100,12 +100,31 @@ export class SubmoduleStrategy {
|
|
|
100
100
|
throw new Error('Could not read submodule commit from project HEAD');
|
|
101
101
|
}
|
|
102
102
|
const targetCommit = match[1];
|
|
103
|
-
// Ensure submodule is initialized in the worktree
|
|
104
|
-
|
|
103
|
+
// Ensure submodule is initialized in the worktree. No timeout: sync() is
|
|
104
|
+
// reached from user-initiated update, which stays unbounded (D10).
|
|
105
|
+
await this.init(worktreePath);
|
|
105
106
|
// Fetch latest objects so the target commit is available, then checkout
|
|
106
107
|
const guidePath = join(worktreePath, GUIDE_RELATIVE_PATH);
|
|
107
108
|
await gitExec(['fetch', 'origin'], guidePath);
|
|
108
109
|
await gitExec(['checkout', targetCommit], guidePath);
|
|
109
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Check out an uninitialized guide submodule at the commit the host repo
|
|
113
|
+
* pins, and report that commit.
|
|
114
|
+
*
|
|
115
|
+
* Only touches the submodule working tree: it runs no `git add` and makes no
|
|
116
|
+
* host commit, so it cannot trip the branch guard. Safe to call when the
|
|
117
|
+
* submodule is already initialized, in which case git does nothing.
|
|
118
|
+
*
|
|
119
|
+
* @param operationPath - repo (or worktree) whose submodule to initialize
|
|
120
|
+
* @param opts.timeoutMs - bound the fetch; callers on a read path set this,
|
|
121
|
+
* install and update leave it unset (D10)
|
|
122
|
+
*/
|
|
123
|
+
async init(operationPath, opts) {
|
|
124
|
+
await gitExec(['submodule', 'update', '--init', GUIDE_RELATIVE_PATH], operationPath, opts?.timeoutMs ? { timeoutMs: opts.timeoutMs } : undefined);
|
|
125
|
+
const guidePath = join(operationPath, GUIDE_RELATIVE_PATH);
|
|
126
|
+
const { stdout } = await gitExec(['rev-parse', '--short', 'HEAD'], guidePath);
|
|
127
|
+
return { commit: stdout };
|
|
128
|
+
}
|
|
110
129
|
}
|
|
111
130
|
//# sourceMappingURL=SubmoduleStrategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubmoduleStrategy.js","sourceRoot":"","sources":["../../../src/guides/strategies/SubmoduleStrategy.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEnE,MAAM,OAAO,iBAAiB;IAC5B,KAAK,CAAC,MAAM,CAAC,WAAmB,EAAE,SAAiB;QACjD,MAAM,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC;YAAE,OAAO,IAAI,CAAC;QAE7C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;YACtD,IAAI,CAAC,OAAO,CAAC,QAAQ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,EAAE,GAAG,MAAM,OAAO,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;QAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { InstallStrategy, InstallResult, UpdateResult, DetectionResult } from '../types.js';
|
|
2
|
+
/** Names of the proxy variables currently set, so a failure can say which applied. */
|
|
3
|
+
export declare function activeProxyEnvVars(env?: NodeJS.ProcessEnv): string[];
|
|
4
|
+
/** Minimal header access shared by undici and WHATWG Response objects. */
|
|
5
|
+
interface HeaderReader {
|
|
6
|
+
get(name: string): string | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* GitHub signals an exhausted rate limit with 403 (or 429) plus
|
|
10
|
+
* x-ratelimit-remaining: 0. Returns a specific message for that case, null
|
|
11
|
+
* for any other failure status.
|
|
12
|
+
*/
|
|
13
|
+
export declare function describeRateLimit(status: number, headers: HeaderReader): string | null;
|
|
2
14
|
/**
|
|
3
15
|
* Parse owner/repo from a GitHub source URL.
|
|
4
16
|
* Supports: https://github.com/{owner}/{repo}.git and https://github.com/{owner}/{repo}
|
|
@@ -7,10 +19,16 @@ export declare function parseGitHubOwnerRepo(source: string): {
|
|
|
7
19
|
owner: string;
|
|
8
20
|
repo: string;
|
|
9
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Whether a raw tarball entry path should be skipped. node-tar calls filter
|
|
24
|
+
* before `strip` is applied, so the path still begins with the archive root
|
|
25
|
+
* ({owner}-{repo}-{hash}/); directory entries end with a slash.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isGitWiringEntry(entryPath: string): boolean;
|
|
10
28
|
export declare class TarballStrategy implements InstallStrategy {
|
|
11
29
|
detect(_projectPath: string, targetDir: string): Promise<DetectionResult | null>;
|
|
12
30
|
install(_projectPath: string, source: string, targetDir: string): Promise<InstallResult>;
|
|
13
|
-
update(_projectPath: string, targetDir: string): Promise<UpdateResult>;
|
|
31
|
+
update(_projectPath: string, targetDir: string, source: string): Promise<UpdateResult>;
|
|
14
32
|
/**
|
|
15
33
|
* Fetch latest tag from remote using git ls-remote. Real failures (network,
|
|
16
34
|
* auth, invalid remote) propagate — only a genuinely tag-less remote yields null.
|
|
@@ -19,4 +37,5 @@ export declare class TarballStrategy implements InstallStrategy {
|
|
|
19
37
|
/** Download tarball from GitHub API and extract to targetDir */
|
|
20
38
|
private downloadAndExtract;
|
|
21
39
|
}
|
|
40
|
+
export {};
|
|
22
41
|
//# sourceMappingURL=TarballStrategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TarballStrategy.d.ts","sourceRoot":"","sources":["../../../src/guides/strategies/TarballStrategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TarballStrategy.d.ts","sourceRoot":"","sources":["../../../src/guides/strategies/TarballStrategy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAWjG,sFAAsF;AACtF,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,EAAE,CAEjF;AAED,0EAA0E;AAC1E,UAAU,YAAY;IACpB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAYtF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAMpF;AAUD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAM3D;AAED,qBAAa,eAAgB,YAAW,eAAe;IAC/C,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAYhF,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAaxF,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA0B5F;;;OAGG;YACW,cAAc;IA4B5B,gEAAgE;YAClD,kBAAkB;CA0DjC"}
|
|
@@ -5,8 +5,36 @@ import { createGunzip } from 'zlib';
|
|
|
5
5
|
import { Readable } from 'stream';
|
|
6
6
|
import { pipeline } from 'stream/promises';
|
|
7
7
|
import { extract } from 'tar';
|
|
8
|
+
import { fetch as undiciFetch, EnvHttpProxyAgent } from 'undici';
|
|
8
9
|
import { VERSION_MARKER_FILE, DEFAULT_SOURCE_GIT } from '../types.js';
|
|
9
10
|
import { gitExec, withNetworkErrorHint } from '../gitExec.js';
|
|
11
|
+
/**
|
|
12
|
+
* Proxy variables honored by the tarball download. Git reads these on its own
|
|
13
|
+
* for the ls-remote half; Node's built-in fetch does not, so the download goes
|
|
14
|
+
* through undici's EnvHttpProxyAgent, which reads the same set (and NO_PROXY).
|
|
15
|
+
*/
|
|
16
|
+
const PROXY_ENV_VARS = ['HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy'];
|
|
17
|
+
/** Names of the proxy variables currently set, so a failure can say which applied. */
|
|
18
|
+
export function activeProxyEnvVars(env = process.env) {
|
|
19
|
+
return PROXY_ENV_VARS.filter((name) => Boolean(env[name]));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* GitHub signals an exhausted rate limit with 403 (or 429) plus
|
|
23
|
+
* x-ratelimit-remaining: 0. Returns a specific message for that case, null
|
|
24
|
+
* for any other failure status.
|
|
25
|
+
*/
|
|
26
|
+
export function describeRateLimit(status, headers) {
|
|
27
|
+
if (status !== 403 && status !== 429)
|
|
28
|
+
return null;
|
|
29
|
+
if (headers.get('x-ratelimit-remaining') !== '0')
|
|
30
|
+
return null;
|
|
31
|
+
const reset = headers.get('x-ratelimit-reset');
|
|
32
|
+
const resetAt = reset && /^\d+$/.test(reset)
|
|
33
|
+
? ` Resets at ${new Date(Number(reset) * 1000).toLocaleTimeString()}.`
|
|
34
|
+
: '';
|
|
35
|
+
return ('GitHub API rate limit exceeded: unauthenticated requests are limited to 60 per hour ' +
|
|
36
|
+
`per source IP, shared by everyone behind the same NAT or proxy.${resetAt}`);
|
|
37
|
+
}
|
|
10
38
|
/**
|
|
11
39
|
* Parse owner/repo from a GitHub source URL.
|
|
12
40
|
* Supports: https://github.com/{owner}/{repo}.git and https://github.com/{owner}/{repo}
|
|
@@ -18,6 +46,23 @@ export function parseGitHubOwnerRepo(source) {
|
|
|
18
46
|
}
|
|
19
47
|
return { owner: match[1], repo: match[2] };
|
|
20
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Top-level entries dropped from the extracted tarball. A tarball install
|
|
51
|
+
* promises plain files with no git wiring, and the guide repo has at times
|
|
52
|
+
* carried its own .gitmodules and a self-referential project-documents/
|
|
53
|
+
* gitlink that would otherwise land inside the consumer's guide directory.
|
|
54
|
+
*/
|
|
55
|
+
const TARBALL_EXCLUDED_ENTRIES = ['.gitmodules', '.gitignore', 'project-documents'];
|
|
56
|
+
/**
|
|
57
|
+
* Whether a raw tarball entry path should be skipped. node-tar calls filter
|
|
58
|
+
* before `strip` is applied, so the path still begins with the archive root
|
|
59
|
+
* ({owner}-{repo}-{hash}/); directory entries end with a slash.
|
|
60
|
+
*/
|
|
61
|
+
export function isGitWiringEntry(entryPath) {
|
|
62
|
+
const parts = entryPath.replace(/^\.\//, '').split('/');
|
|
63
|
+
const relative = parts.slice(1).join('/');
|
|
64
|
+
return TARBALL_EXCLUDED_ENTRIES.some((name) => relative === name || relative === `${name}/` || relative.startsWith(`${name}/`));
|
|
65
|
+
}
|
|
21
66
|
export class TarballStrategy {
|
|
22
67
|
async detect(_projectPath, targetDir) {
|
|
23
68
|
const markerPath = join(targetDir, VERSION_MARKER_FILE);
|
|
@@ -25,7 +70,7 @@ export class TarballStrategy {
|
|
|
25
70
|
return null;
|
|
26
71
|
try {
|
|
27
72
|
const version = readFileSync(markerPath, 'utf-8').trim() || null;
|
|
28
|
-
return { method: '
|
|
73
|
+
return { method: 'tarball', version, source: null };
|
|
29
74
|
}
|
|
30
75
|
catch {
|
|
31
76
|
return null;
|
|
@@ -39,9 +84,9 @@ export class TarballStrategy {
|
|
|
39
84
|
}
|
|
40
85
|
await this.downloadAndExtract(resolvedSource, latestTag, targetDir);
|
|
41
86
|
writeFileSync(join(targetDir, VERSION_MARKER_FILE), latestTag, 'utf-8');
|
|
42
|
-
return { success: true, version: latestTag, method: '
|
|
87
|
+
return { success: true, version: latestTag, method: 'tarball', path: targetDir };
|
|
43
88
|
}
|
|
44
|
-
async update(_projectPath, targetDir) {
|
|
89
|
+
async update(_projectPath, targetDir, source) {
|
|
45
90
|
const markerPath = join(targetDir, VERSION_MARKER_FILE);
|
|
46
91
|
let previousVersion = null;
|
|
47
92
|
try {
|
|
@@ -50,20 +95,18 @@ export class TarballStrategy {
|
|
|
50
95
|
catch {
|
|
51
96
|
// No previous version
|
|
52
97
|
}
|
|
53
|
-
// Determine source from the default (marker doesn't store it)
|
|
54
|
-
const source = DEFAULT_SOURCE_GIT;
|
|
55
98
|
const latestTag = await this.fetchLatestTag(source);
|
|
56
99
|
if (!latestTag) {
|
|
57
100
|
throw new Error('Could not determine latest version from remote.');
|
|
58
101
|
}
|
|
59
102
|
if (previousVersion === latestTag) {
|
|
60
|
-
return { success: true, previousVersion, newVersion: latestTag, method: '
|
|
103
|
+
return { success: true, previousVersion, newVersion: latestTag, method: 'tarball' };
|
|
61
104
|
}
|
|
62
105
|
// Remove existing contents and re-download
|
|
63
106
|
rmSync(targetDir, { recursive: true, force: true });
|
|
64
107
|
await this.downloadAndExtract(source, latestTag, targetDir);
|
|
65
108
|
writeFileSync(join(targetDir, VERSION_MARKER_FILE), latestTag, 'utf-8');
|
|
66
|
-
return { success: true, previousVersion, newVersion: latestTag, method: '
|
|
109
|
+
return { success: true, previousVersion, newVersion: latestTag, method: 'tarball' };
|
|
67
110
|
}
|
|
68
111
|
/**
|
|
69
112
|
* Fetch latest tag from remote using git ls-remote. Real failures (network,
|
|
@@ -96,31 +139,46 @@ export class TarballStrategy {
|
|
|
96
139
|
async downloadAndExtract(source, tag, targetDir) {
|
|
97
140
|
const { owner, repo } = parseGitHubOwnerRepo(source);
|
|
98
141
|
const url = `https://api.github.com/repos/${owner}/${repo}/tarball/${tag}`;
|
|
99
|
-
|
|
142
|
+
// The ls-remote half already went through git, which honors the proxy
|
|
143
|
+
// variables itself; a failure here is therefore the download specifically.
|
|
144
|
+
const proxyVars = activeProxyEnvVars();
|
|
145
|
+
const via = proxyVars.length > 0 ? ` via proxy (${proxyVars.join(', ')})` : '';
|
|
146
|
+
const failurePrefix = `Downloading guide tarball from ${url}${via} failed`;
|
|
147
|
+
// Closed in finally: an open keep-alive socket would otherwise hold the
|
|
148
|
+
// CLI process alive until the agent's idle timeout.
|
|
149
|
+
const dispatcher = new EnvHttpProxyAgent();
|
|
100
150
|
try {
|
|
101
|
-
response
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
151
|
+
let response;
|
|
152
|
+
try {
|
|
153
|
+
response = await undiciFetch(url, {
|
|
154
|
+
headers: { Accept: 'application/vnd.github+json' },
|
|
155
|
+
redirect: 'follow',
|
|
156
|
+
dispatcher,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
// undici throws TypeError('fetch failed') with the real DNS/connection
|
|
161
|
+
// reason on err.cause.message — surface that, not the generic wrapper text.
|
|
162
|
+
const cause = err instanceof Error && err.cause instanceof Error ? err.cause.message : undefined;
|
|
163
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
164
|
+
throw new Error(withNetworkErrorHint(`${failurePrefix}: ${cause ? `${message}: ${cause}` : message}`));
|
|
165
|
+
}
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
const rateLimit = describeRateLimit(response.status, response.headers);
|
|
168
|
+
throw new Error(rateLimit ?? `${failurePrefix}: HTTP ${response.status} ${response.statusText}`);
|
|
169
|
+
}
|
|
170
|
+
if (!response.body) {
|
|
171
|
+
throw new Error(`${failurePrefix}: empty response body`);
|
|
172
|
+
}
|
|
173
|
+
mkdirSync(targetDir, { recursive: true });
|
|
174
|
+
// GitHub tarballs have a top-level directory like {owner}-{repo}-{hash}/
|
|
175
|
+
// We strip 1 level and extract directly into targetDir
|
|
176
|
+
const nodeStream = Readable.fromWeb(response.body);
|
|
177
|
+
await pipeline(nodeStream, createGunzip(), extract({ cwd: targetDir, strip: 1, filter: (entryPath) => !isGitWiringEntry(entryPath) }));
|
|
115
178
|
}
|
|
116
|
-
|
|
117
|
-
|
|
179
|
+
finally {
|
|
180
|
+
await dispatcher.close();
|
|
118
181
|
}
|
|
119
|
-
mkdirSync(targetDir, { recursive: true });
|
|
120
|
-
// GitHub tarballs have a top-level directory like {owner}-{repo}-{hash}/
|
|
121
|
-
// We strip 1 level and extract directly into targetDir
|
|
122
|
-
const nodeStream = Readable.fromWeb(response.body);
|
|
123
|
-
await pipeline(nodeStream, createGunzip(), extract({ cwd: targetDir, strip: 1 }));
|
|
124
182
|
}
|
|
125
183
|
}
|
|
126
184
|
//# sourceMappingURL=TarballStrategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TarballStrategy.js","sourceRoot":"","sources":["../../../src/guides/strategies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
|
/** Installation method used for the ai-project-guide */
|
|
2
|
-
export type GuideMethod = 'submodule' | 'clone' | '
|
|
2
|
+
export type GuideMethod = 'submodule' | 'clone' | 'tarball';
|
|
3
|
+
/** Canonical guide methods, in the order they are presented to users. */
|
|
4
|
+
export declare const GUIDE_METHODS: readonly GuideMethod[];
|
|
5
|
+
/**
|
|
6
|
+
* Deprecated strategy names accepted on input, mapped to their canonical
|
|
7
|
+
* replacement. Callers check this to emit a deprecation warning without
|
|
8
|
+
* re-comparing strings. This is the only place an alias is spelled in core
|
|
9
|
+
* source outside the ConfigKeys enum (which keeps `manual` so existing
|
|
10
|
+
* shared config files still validate).
|
|
11
|
+
*/
|
|
12
|
+
export declare const GUIDE_METHOD_DEPRECATED_ALIASES: Readonly<Record<string, GuideMethod>>;
|
|
13
|
+
/**
|
|
14
|
+
* Normalize a strategy name from any input boundary (config value, CLI
|
|
15
|
+
* `--strategy` flag, MCP tool parameter) into a canonical GuideMethod.
|
|
16
|
+
* Throws when the input is neither canonical nor a known deprecated alias.
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeGuideMethod(input: string): GuideMethod;
|
|
19
|
+
/**
|
|
20
|
+
* True when `input` is a deprecated alias rather than a canonical method.
|
|
21
|
+
* Lets a boundary decide whether to print the D5 deprecation warning.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isDeprecatedGuideMethodAlias(input: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The one spelling of the D5 deprecation warning. The CLI prints it to stderr
|
|
26
|
+
* and the MCP server returns it as a notice, so the sentence lives here rather
|
|
27
|
+
* than at each boundary.
|
|
28
|
+
*/
|
|
29
|
+
export declare function guideMethodDeprecationMessage(alias: string, method: GuideMethod): string;
|
|
30
|
+
/**
|
|
31
|
+
* The installation strategies offered to users, with the one-line trade-off
|
|
32
|
+
* shown for each. `cf init --help`, `cf guides install --help` and the MCP
|
|
33
|
+
* `guide_install` description all render from this single descriptor (D8),
|
|
34
|
+
* so the wording cannot drift between surfaces. Adding a GuideMethod without
|
|
35
|
+
* an entry here is a compile error.
|
|
36
|
+
*/
|
|
37
|
+
export declare const GUIDE_STRATEGIES: Record<GuideMethod, {
|
|
38
|
+
summary: string;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Checkout state of a submodule-installed guide, as `git submodule status`
|
|
42
|
+
* reports it. Only meaningful for the submodule method.
|
|
43
|
+
*/
|
|
44
|
+
export type SubmoduleCheckoutState = 'in_sync' | 'out_of_sync' | 'not_initialized';
|
|
45
|
+
/** Human-readable labels for each checkout state, used in CLI and tool output. */
|
|
46
|
+
export declare const CHECKOUT_STATE_LABELS: Record<SubmoduleCheckoutState, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Upper bound on the automatic `git submodule update --init` performed by a
|
|
49
|
+
* read command. A blackholed proxy would otherwise block for the OS TCP
|
|
50
|
+
* timeout. User-initiated install and update stay unbounded (D10).
|
|
51
|
+
*/
|
|
52
|
+
export declare const GUIDE_INIT_TIMEOUT_MS = 60000;
|
|
3
53
|
/** Full status of a guide installation */
|
|
4
54
|
export interface GuideInfo {
|
|
5
55
|
installed: boolean;
|
|
6
56
|
method: GuideMethod | null;
|
|
57
|
+
/**
|
|
58
|
+
* Submodule checkout state; null for clone/tarball installs and when no
|
|
59
|
+
* guide is installed.
|
|
60
|
+
*/
|
|
61
|
+
checkout: SubmoduleCheckoutState | null;
|
|
7
62
|
version: string | null;
|
|
8
63
|
path: string;
|
|
9
64
|
source: string;
|
|
@@ -11,12 +66,32 @@ export interface GuideInfo {
|
|
|
11
66
|
updateAvailable: boolean;
|
|
12
67
|
usingBundledPrompt: boolean;
|
|
13
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Outcome of GuideManager.ensureCheckout().
|
|
71
|
+
*
|
|
72
|
+
* `none` means nothing needed doing; `initialized` means an uninitialized
|
|
73
|
+
* submodule was checked out; `warned` means the checkout differs from the
|
|
74
|
+
* pinned commit and was deliberately left alone (D2).
|
|
75
|
+
*/
|
|
76
|
+
export interface EnsureCheckoutResult {
|
|
77
|
+
action: 'none' | 'initialized' | 'warned';
|
|
78
|
+
/** Short SHA of the checked-out guide commit, when action is 'initialized'. */
|
|
79
|
+
commit?: string;
|
|
80
|
+
/** Human-readable notice, present whenever action is not 'none'. */
|
|
81
|
+
message?: string;
|
|
82
|
+
}
|
|
14
83
|
/** Result of a guide installation */
|
|
15
84
|
export interface InstallResult {
|
|
16
85
|
success: boolean;
|
|
17
86
|
version: string | null;
|
|
18
87
|
method: GuideMethod;
|
|
19
88
|
path: string;
|
|
89
|
+
/**
|
|
90
|
+
* Set when the requested strategy was named by a deprecated alias (e.g.
|
|
91
|
+
* `manual`), carrying the original spelling. Callers print a deprecation
|
|
92
|
+
* warning; absent when the canonical name was used (D5).
|
|
93
|
+
*/
|
|
94
|
+
deprecatedAlias?: string;
|
|
20
95
|
}
|
|
21
96
|
/** Result of a guide update */
|
|
22
97
|
export interface UpdateResult {
|
|
@@ -52,9 +127,14 @@ export interface DetectionResult {
|
|
|
52
127
|
/** Strategy interface for guide installation methods */
|
|
53
128
|
export interface InstallStrategy {
|
|
54
129
|
install(projectPath: string, source: string, targetDir: string): Promise<InstallResult>;
|
|
55
|
-
update(projectPath: string, targetDir: string): Promise<UpdateResult>;
|
|
130
|
+
update(projectPath: string, targetDir: string, source: string): Promise<UpdateResult>;
|
|
56
131
|
detect(projectPath: string, targetDir: string): Promise<DetectionResult | null>;
|
|
57
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Stated wherever the guide directory is described, so a user learns the rule
|
|
135
|
+
* before `cf guides update` overwrites an edit they made in place (D9, #82).
|
|
136
|
+
*/
|
|
137
|
+
export declare const GUIDE_MANAGED_NOTICE: string;
|
|
58
138
|
export declare const DEFAULT_SOURCE_GIT = "https://github.com/ecorkran/ai-project-guide.git";
|
|
59
139
|
export declare const DEFAULT_SOURCE_API = "https://api.github.com/repos/ecorkran/ai-project-guide";
|
|
60
140
|
export declare const GUIDE_RELATIVE_PATH = "project-documents/ai-project-guide";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/guides/types.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/guides/types.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,CAAC;AAE5D,yEAAyE;AACzE,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAAsC,CAAC;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAEjF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAa/D;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAExF;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,WAAW,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAMrE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,aAAa,GAAG,iBAAiB,CAAC;AAEnF,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAIxE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAE5C,0CAA0C;AAC1C,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM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