@mnemonik/shared 7.140.1 → 7.140.3
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/codeScanner.d.ts +46 -1
- package/dist/codeScanner.d.ts.map +1 -1
- package/dist/codeScanner.js +100 -12
- package/dist/codeScanner.js.map +1 -1
- package/dist/contextBudget.d.ts +2 -2
- package/dist/contextBudget.d.ts.map +1 -1
- package/dist/contextBudget.js +3 -4
- package/dist/contextBudget.js.map +1 -1
- package/dist/gitEditDetector.d.ts +11 -6
- package/dist/gitEditDetector.d.ts.map +1 -1
- package/dist/gitEditDetector.js +119 -9
- package/dist/gitEditDetector.js.map +1 -1
- package/dist/hookRuntime.d.ts +18 -8
- package/dist/hookRuntime.d.ts.map +1 -1
- package/dist/hookRuntime.js +31 -20
- package/dist/hookRuntime.js.map +1 -1
- package/dist/hookTrace.d.ts +149 -0
- package/dist/hookTrace.d.ts.map +1 -0
- package/dist/hookTrace.js +483 -0
- package/dist/hookTrace.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/instructions.d.ts.map +1 -1
- package/dist/instructions.js +1 -1
- package/dist/projectIdentityFile.d.ts +13 -0
- package/dist/projectIdentityFile.d.ts.map +1 -1
- package/dist/projectIdentityFile.js +31 -18
- package/dist/projectIdentityFile.js.map +1 -1
- package/dist/protectedPaths.d.ts +6 -0
- package/dist/protectedPaths.d.ts.map +1 -1
- package/dist/protectedPaths.js +15 -6
- package/dist/protectedPaths.js.map +1 -1
- package/dist/repositoryRoot.d.ts +20 -8
- package/dist/repositoryRoot.d.ts.map +1 -1
- package/dist/repositoryRoot.js +167 -79
- package/dist/repositoryRoot.js.map +1 -1
- package/dist/runtimeReader.d.ts +1 -1
- package/dist/runtimeReader.d.ts.map +1 -1
- package/dist/runtimeReader.js.map +1 -1
- package/package.json +2 -2
- package/src/codeScanner.ts +115 -9
- package/src/contextBudget.ts +3 -4
- package/src/gitEditDetector.ts +113 -8
- package/src/hookRuntime.ts +39 -27
- package/src/hookTrace.ts +588 -0
- package/src/index.ts +4 -0
- package/src/instructions.ts +1 -1
- package/src/projectIdentityFile.ts +34 -20
- package/src/protectedPaths.ts +18 -7
- package/src/repositoryRoot.ts +188 -82
- package/src/runtimeReader.ts +6 -1
- package/test-fixtures/identity/runner.d.mts +1 -1
- package/test-fixtures/identity/runner.mjs +299 -25
- package/tests/hookTrace.test.ts +350 -0
- package/tests/nearestProjectIdentity.test.ts +253 -0
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export { MCP_INSTRUCTIONS, MCP_INSTRUCTIONS_RAW, getMcpInstructions } from './instructions.js';
|
|
8
8
|
export { USAGE_GUIDE } from './usageGuide.js';
|
|
9
9
|
export declare const SCANNER_HEARTBEAT_INTERVAL_MS = 300000;
|
|
10
|
-
export { CodeScanner, MAX_SCANNED_FILE_BYTES, MAX_PUSH_CHUNK_CONTENT_LENGTH, AUTHORITY_FILE_MATCHERS, BUILT_IN_IGNORE_DIRS, DEFAULT_INCLUDE_EXTENSIONS, languageForExtension, makeIgnoreMatcher, isGitBoundary, FIXTURE_PATH_RE, isFixturePath, isSecretFile, isAuthorityOnlyPath, isCursorRulePath, logAstCapabilityOnce, type CodeChunk, type ScanOptions, type IndexExcludedFile, type IndexRuleFiles, } from './codeScanner.js';
|
|
10
|
+
export { CodeScanner, MAX_SCANNED_FILE_BYTES, MAX_PUSH_CHUNK_CONTENT_LENGTH, AUTHORITY_FILE_MATCHERS, BUILT_IN_IGNORE_DIRS, DEFAULT_INCLUDE_EXTENSIONS, languageForExtension, makeIgnoreMatcher, isGitBoundary, isProjectBoundary, rootProjectId, SCANNER_MAX_DEPTH, isLinkedWorktreeCheckout, FIXTURE_PATH_RE, isFixturePath, isSecretFile, isAuthorityOnlyPath, isCursorRulePath, logAstCapabilityOnce, type CodeChunk, type ScanOptions, type IndexExcludedFile, type IndexRuleFiles, } from './codeScanner.js';
|
|
11
11
|
export { INDEX_EXCLUSION_REASONS, BINARY_SNIFF_BYTES, MINIFIED_AVERAGE_LINE_LENGTH, MINIFIED_LONG_LINE_BYTES, DATA_DUMP_INSERT_THRESHOLD, NESTED_IGNORE_TAG, GITATTRIBUTES_TAG, classifyForIndex, softDefaultForPath, softDefaultForDirectory, softDefaultForContent, parseGitattributes, linguistAttributesFor, gitattributesCanReinclude, indexExclusionLabel, indexExclusionNotice, isIndexExclusionReason, encodeNestedIgnoreLine, encodeGitattributesLine, decodeIndexRules, type IndexExclusionReason, type IndexExclusion, type IndexClassification, type IgnoreFileVerdict, type GitattributesLayer, type GitattributesRule, type LinguistAttributes, type ClassifyForIndexOptions, type DecodedIndexRules, } from './indexClassifier.js';
|
|
12
12
|
export { makeIndexJudge, type IndexJudge, type IndexJudgement } from './indexJudge.js';
|
|
13
13
|
export { AST_LANGUAGE_IDS, QUERY_CHAIN, VENDORED_ARTIFACT_DIR, astArtifactReport, astCapabilityReport, grammarArtifactBasename, loadGrammar, loadedGrammarIds, resolveAstLanguage, type AstLanguageId, type GrammarBinding, type GrammarLoad, type GrammarUnavailableReason, } from './ast/grammars.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,eAAO,MAAM,6BAA6B,SAAU,CAAC;AACrD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,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V,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,GACd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,yBAAyB,EACzB,iCAAiC,EACjC,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,KAAK,YAAY,GAClB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export { MCP_INSTRUCTIONS, MCP_INSTRUCTIONS_RAW, getMcpInstructions } from './instructions.js';
|
|
8
8
|
export { USAGE_GUIDE } from './usageGuide.js';
|
|
9
9
|
export const SCANNER_HEARTBEAT_INTERVAL_MS = 300_000;
|
|
10
|
-
export { CodeScanner, MAX_SCANNED_FILE_BYTES, MAX_PUSH_CHUNK_CONTENT_LENGTH, AUTHORITY_FILE_MATCHERS, BUILT_IN_IGNORE_DIRS, DEFAULT_INCLUDE_EXTENSIONS, languageForExtension, makeIgnoreMatcher, isGitBoundary, FIXTURE_PATH_RE, isFixturePath, isSecretFile, isAuthorityOnlyPath, isCursorRulePath, logAstCapabilityOnce, } from './codeScanner.js';
|
|
10
|
+
export { CodeScanner, MAX_SCANNED_FILE_BYTES, MAX_PUSH_CHUNK_CONTENT_LENGTH, AUTHORITY_FILE_MATCHERS, BUILT_IN_IGNORE_DIRS, DEFAULT_INCLUDE_EXTENSIONS, languageForExtension, makeIgnoreMatcher, isGitBoundary, isProjectBoundary, rootProjectId, SCANNER_MAX_DEPTH, isLinkedWorktreeCheckout, FIXTURE_PATH_RE, isFixturePath, isSecretFile, isAuthorityOnlyPath, isCursorRulePath, logAstCapabilityOnce, } from './codeScanner.js';
|
|
11
11
|
export { INDEX_EXCLUSION_REASONS, BINARY_SNIFF_BYTES, MINIFIED_AVERAGE_LINE_LENGTH, MINIFIED_LONG_LINE_BYTES, DATA_DUMP_INSERT_THRESHOLD, NESTED_IGNORE_TAG, GITATTRIBUTES_TAG, classifyForIndex, softDefaultForPath, softDefaultForDirectory, softDefaultForContent, parseGitattributes, linguistAttributesFor, gitattributesCanReinclude, indexExclusionLabel, indexExclusionNotice, isIndexExclusionReason, encodeNestedIgnoreLine, encodeGitattributesLine, decodeIndexRules, } from './indexClassifier.js';
|
|
12
12
|
export { makeIndexJudge } from './indexJudge.js';
|
|
13
13
|
export { AST_LANGUAGE_IDS, QUERY_CHAIN, VENDORED_ARTIFACT_DIR, astArtifactReport, astCapabilityReport, grammarArtifactBasename, loadGrammar, loadedGrammarIds, resolveAstLanguage, } from './ast/grammars.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAO,CAAC;AACrD,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,G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AAC;AAE1D,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAShC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,yBAAyB,EACzB,iCAAiC,EACjC,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,GAEb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/instructions.d.ts
CHANGED
|
@@ -167,7 +167,7 @@ export declare function getMcpInstructions(): string;
|
|
|
167
167
|
* Raw instructions content (always returns the content, ignores env var).
|
|
168
168
|
* Use getMcpInstructions() for production code.
|
|
169
169
|
*/
|
|
170
|
-
export declare const MCP_INSTRUCTIONS_RAW = "Mnemonik provides persistent project memory: decisions, rationale, tasks, and policies across sessions. If no block begins \"PROJECT_CONTEXT schemaVersion=\", session_bootstrap({
|
|
170
|
+
export declare const MCP_INSTRUCTIONS_RAW = "Mnemonik provides persistent project memory: decisions, rationale, tasks, and policies across sessions. If no block begins \"PROJECT_CONTEXT schemaVersion=\", session_bootstrap({}) loads project context; installed hooks supply the project. With that block, context is loaded and no session_bootstrap call is needed. Code and docs show current artifacts, git shows changes, and memory carries the why; memory_search recalls rationale or intent, then Grep or Read verifies current source.\n\nWhat I learn about you belongs in Companion; what I learn about this project belongs here.\n\nmemory_discover supplies exact schemas and examples for unfamiliar methods; memory_tools runs their async JavaScript.\n\nRetrieval pages use hydrated for complete records, index for pointer rows, extent for totals, and cursor for continuation. Select relevant IDs before hydrating originals; a refined query or cursor reveals more without paging full bodies to discover what exists.\n\nProject work items live in tasks. A pending list requires action:\"list\" and status:\"pending\". A complete listing combines hydrated and index and follows cursor until null.\n\nWhich tool for what:\n- memory_get: hydrates exact originals by id.\n- memory_add: records an experience: a decision and why, what the user said, what you found.\n- memory_state: corrects wrong, outdated, or conflicting memory.\n- memory_info: explains confidence or origin when memory looks suspect.\n- memory_links: connects related decisions so they surface together.\n- assist: measures coverage when search results are thin or empty.\n- search_summaries: finds past work by topic or date across sessions.\n- policy: stores durable enforced rules or preferences, not memories.\n- tasks: creates follow-up work and closes completed work.\n- code_search: finds conceptual code when source wording differs.\n- memory_search: finds rationale, intent, decisions, and prior work.\n- memory_ingest: brings the project's docs and code comments into memory when asked.";
|
|
171
171
|
/**
|
|
172
172
|
* Default export for convenience.
|
|
173
173
|
* Note: This respects the MNEMONIK_INSTRUCTIONS_ENABLED env var.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0JG;AA4BH;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAa3C;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0JG;AA4BH;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAa3C;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,i+DAAuB,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAuB,CAAC"}
|
package/dist/instructions.js
CHANGED
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
*/
|
|
156
156
|
// Dynamic response orchestration remains authoritative. This universal floor stays
|
|
157
157
|
// self-scoping when project context was already loaded through another channel.
|
|
158
|
-
const INSTRUCTIONS_CONTENT = `Mnemonik provides persistent project memory: decisions, rationale, tasks, and policies across sessions. If no block begins "PROJECT_CONTEXT schemaVersion=", session_bootstrap({
|
|
158
|
+
const INSTRUCTIONS_CONTENT = `Mnemonik provides persistent project memory: decisions, rationale, tasks, and policies across sessions. If no block begins "PROJECT_CONTEXT schemaVersion=", session_bootstrap({}) loads project context; installed hooks supply the project. With that block, context is loaded and no session_bootstrap call is needed. Code and docs show current artifacts, git shows changes, and memory carries the why; memory_search recalls rationale or intent, then Grep or Read verifies current source.
|
|
159
159
|
|
|
160
160
|
What I learn about you belongs in Companion; what I learn about this project belongs here.
|
|
161
161
|
|
|
@@ -21,7 +21,20 @@ export type IdentityFileResult = {
|
|
|
21
21
|
export declare function parseIdentityFile(text: string): Exclude<IdentityFileResult, {
|
|
22
22
|
kind: 'absent';
|
|
23
23
|
}>;
|
|
24
|
+
/**
|
|
25
|
+
* A `.mnemonik.json` that holds configuration but no identity: a JSON object
|
|
26
|
+
* with no `projectId` that names schema 1 or no schema. Invalid identities,
|
|
27
|
+
* and any file naming another schema (which may carry its identity under other
|
|
28
|
+
* keys), are not.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isConfigurationOnly(text: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Read a folder's identity file. With `configurationOnlyAbsent` (and with
|
|
33
|
+
* `selectedRoot`, folders ticked during install), a configuration-only file is
|
|
34
|
+
* no identity: the folder is not a project of its own.
|
|
35
|
+
*/
|
|
24
36
|
export declare function readIdentityFile(dir: string, options?: {
|
|
25
37
|
selectedRoot?: boolean;
|
|
38
|
+
configurationOnlyAbsent?: boolean;
|
|
26
39
|
}): Promise<IdentityFileResult>;
|
|
27
40
|
//# sourceMappingURL=projectIdentityFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectIdentityFile.d.ts","sourceRoot":"","sources":["../src/projectIdentityFile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE,eAAO,MAAM,eAAe,UAAW,OAAO,KAAG,KAAK,IAAI,MACD,CAAC;AAS1D,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,CAAC,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CA0D/F;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,
|
|
1
|
+
{"version":3,"file":"projectIdentityFile.d.ts","sourceRoot":"","sources":["../src/projectIdentityFile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE,eAAO,MAAM,eAAe,UAAW,OAAO,KAAG,KAAK,IAAI,MACD,CAAC;AAS1D,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,CAAC,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CA0D/F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAazD;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAAO,GAC1E,OAAO,CAAC,kBAAkB,CAAC,CAmB7B"}
|
|
@@ -68,6 +68,30 @@ export function parseIdentityFile(text) {
|
|
|
68
68
|
},
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A `.mnemonik.json` that holds configuration but no identity: a JSON object
|
|
73
|
+
* with no `projectId` that names schema 1 or no schema. Invalid identities,
|
|
74
|
+
* and any file naming another schema (which may carry its identity under other
|
|
75
|
+
* keys), are not.
|
|
76
|
+
*/
|
|
77
|
+
export function isConfigurationOnly(text) {
|
|
78
|
+
try {
|
|
79
|
+
const value = JSON.parse(text);
|
|
80
|
+
return (!!value &&
|
|
81
|
+
typeof value === 'object' &&
|
|
82
|
+
!Array.isArray(value) &&
|
|
83
|
+
!('projectId' in value) &&
|
|
84
|
+
(!('schemaVersion' in value) || value.schemaVersion === 1));
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Read a folder's identity file. With `configurationOnlyAbsent` (and with
|
|
92
|
+
* `selectedRoot`, folders ticked during install), a configuration-only file is
|
|
93
|
+
* no identity: the folder is not a project of its own.
|
|
94
|
+
*/
|
|
71
95
|
export async function readIdentityFile(dir, options = {}) {
|
|
72
96
|
const path = join(dir, '.mnemonik.json');
|
|
73
97
|
try {
|
|
@@ -77,24 +101,13 @@ export async function readIdentityFile(dir, options = {}) {
|
|
|
77
101
|
if (!stat.isFile())
|
|
78
102
|
return { kind: 'malformed', detail: 'identity path is not a regular file' };
|
|
79
103
|
const text = await readFile(path, 'utf8');
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (value &&
|
|
88
|
-
typeof value === 'object' &&
|
|
89
|
-
!Array.isArray(value) &&
|
|
90
|
-
!('projectId' in value) &&
|
|
91
|
-
(!('schemaVersion' in value) || value.schemaVersion === 1))
|
|
92
|
-
return { kind: 'absent' };
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
/* The strict parser supplies the diagnostic. */
|
|
96
|
-
}
|
|
97
|
-
}
|
|
104
|
+
// A ticked folder with configuration but no identity is a new project, and
|
|
105
|
+
// a configuration-only file met walking up is not a project boundary. Keep
|
|
106
|
+
// invalid identities, non-regular files and any file that names a schema
|
|
107
|
+
// other than 1 on the strict refusal path: a later schema may carry its
|
|
108
|
+
// identity under other keys, and setup must not replace it.
|
|
109
|
+
if ((options.selectedRoot || options.configurationOnlyAbsent) && isConfigurationOnly(text))
|
|
110
|
+
return { kind: 'absent' };
|
|
98
111
|
return parseIdentityFile(text);
|
|
99
112
|
}
|
|
100
113
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projectIdentityFile.js","sourceRoot":"","sources":["../src/projectIdentityFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,MAAM,cAAc,GAAG,2EAA2E,CAAC;AACnG,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAc,EAAmB,EAAE,CACjE,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,eAAe;IACf,WAAW;IACX,aAAa;IACb,uBAAuB;CACxB,CAAC,CAAC;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC,CAAC;AAe/D,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,qBAAsB,KAAe,CAAC,OAAO,EAAE,EAAE,CAAC;IACxF,CAAC;IACD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,O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AM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,cAAc,EAAE;YAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;QAC3E,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,qCAAqC,EAAE,CAAC;QAChG,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,2EAA2E;QAC3E,2EAA2E;QAC3E,yEAAyE;QACzE,wEAAwE;QACxE,4DAA4D;QAC5D,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,uBAAuB,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC;YACxF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC5B,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAClF,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,8BAA+B,KAAe,CAAC,OAAO,EAAE,EAAE,CAAC;IACjG,CAAC;AACH,CAAC"}
|
package/dist/protectedPaths.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
type Platform = NodeJS.Platform;
|
|
2
|
+
/**
|
|
3
|
+
* Mnemonik's local state folder: the same answer as `stateDirectory` in
|
|
4
|
+
* @mnemonik/local-setup, which depends on this package and so cannot be
|
|
5
|
+
* imported here.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mnemonikStateDirectory(platform?: Platform, env?: NodeJS.ProcessEnv, home?: string): string;
|
|
2
8
|
/** Local state and credential locations that Mnemonik must never scan. */
|
|
3
9
|
export declare function protectedLocalPaths(platform?: Platform, env?: NodeJS.ProcessEnv, home?: string): string[];
|
|
4
10
|
/** True when candidate is the protected path itself or lies below it. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protectedPaths.d.ts","sourceRoot":"","sources":["../src/protectedPaths.ts"],"names":[],"mappings":"AAGA,KAAK,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAMhC,0EAA0E;AAC1E,wBAAgB,mBAAmB,CACjC,QAAQ,GAAE,QAA2B,EACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,IAAI,GAAE,MAAkB,GACvB,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"protectedPaths.d.ts","sourceRoot":"","sources":["../src/protectedPaths.ts"],"names":[],"mappings":"AAGA,KAAK,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAMhC;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,GAAE,QAA2B,EACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,IAAI,GAAE,MAAkB,GACvB,MAAM,CAMR;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CACjC,QAAQ,GAAE,QAA2B,EACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,IAAI,GAAE,MAAkB,GACvB,MAAM,EAAE,CAkCV;AAQD,yEAAyE;AACzE,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,cAAc,GAAE,SAAS,MAAM,EAA0B,EACzD,QAAQ,GAAE,QAA2B,GACpC,OAAO,CAWT;AAED,2EAA2E;AAC3E,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,SAAS,MAAM,EAA0B,EACzD,QAAQ,GAAE,QAA2B,GACpC,MAAM,EAAE,CAEV"}
|
package/dist/protectedPaths.js
CHANGED
|
@@ -3,17 +3,26 @@ import { posix, win32 } from 'node:path';
|
|
|
3
3
|
function pathsFor(platform) {
|
|
4
4
|
return platform === 'win32' ? win32 : posix;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Mnemonik's local state folder: the same answer as `stateDirectory` in
|
|
8
|
+
* @mnemonik/local-setup, which depends on this package and so cannot be
|
|
9
|
+
* imported here.
|
|
10
|
+
*/
|
|
11
|
+
export function mnemonikStateDirectory(platform = process.platform, env = process.env, home = homedir()) {
|
|
12
|
+
if (env.MNEMONIK_STATE_DIR)
|
|
13
|
+
return env.MNEMONIK_STATE_DIR;
|
|
14
|
+
if (platform === 'win32')
|
|
15
|
+
return win32.join(env.LOCALAPPDATA || win32.join(home, 'AppData', 'Local'), 'Mnemonik');
|
|
16
|
+
if (platform === 'darwin')
|
|
17
|
+
return posix.join(home, 'Library', 'Application Support', 'Mnemonik');
|
|
18
|
+
return posix.join(env.XDG_STATE_HOME || posix.join(home, '.local', 'state'), 'mnemonik');
|
|
19
|
+
}
|
|
6
20
|
/** Local state and credential locations that Mnemonik must never scan. */
|
|
7
21
|
export function protectedLocalPaths(platform = process.platform, env = process.env, home = homedir()) {
|
|
8
22
|
const path = pathsFor(platform);
|
|
9
23
|
const localAppData = env.LOCALAPPDATA || win32.join(home, 'AppData', 'Local');
|
|
10
24
|
const appData = env.APPDATA || win32.join(home, 'AppData', 'Roaming');
|
|
11
|
-
const state = env
|
|
12
|
-
(platform === 'win32'
|
|
13
|
-
? win32.join(localAppData, 'Mnemonik')
|
|
14
|
-
: platform === 'darwin'
|
|
15
|
-
? posix.join(home, 'Library', 'Application Support', 'Mnemonik')
|
|
16
|
-
: posix.join(env.XDG_STATE_HOME || posix.join(home, '.local', 'state'), 'mnemonik'));
|
|
25
|
+
const state = mnemonikStateDirectory(platform, env, home);
|
|
17
26
|
const common = [
|
|
18
27
|
state,
|
|
19
28
|
path.join(home, '.mnemonik'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protectedPaths.js","sourceRoot":"","sources":["../src/protectedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAqB,MAAM,WAAW,CAAC;AAI5D,SAAS,QAAQ,CAAC,QAAkB;IAClC,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"protectedPaths.js","sourceRoot":"","sources":["../src/protectedPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAqB,MAAM,WAAW,CAAC;AAI5D,SAAS,QAAQ,CAAC,QAAkB;IAClC,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAQ,GAAa,OAAO,CAAC,QAAQ,EACrC,GAAG,GAAsB,OAAO,CAAC,GAAG,EACpC,IAAI,GAAW,OAAO,EAAE;IAExB,IAAI,GAAG,CAAC,kBAAkB;QAAE,OAAO,GAAG,CAAC,kBAAkB,CAAC;IAC1D,IAAI,QAAQ,KAAK,OAAO;QACtB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;IAC1F,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE,UAAU,CAAC,CAAC;IACjG,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,IAAI,KAAK,C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EAAE,EACzD,QAAQ,GAAa,OAAO,CAAC,QAAQ;IAErC,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC/C,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,CACL,QAAQ,KAAK,EAAE;YACf,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAC3F,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,wBAAwB,CACtC,IAAY,EACZ,cAAc,GAAsB,mBAAmB,EAAE,EACzD,QAAQ,GAAa,OAAO,CAAC,QAAQ;IAErC,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,oBAAoB,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AACjG,CAAC"}
|
package/dist/repositoryRoot.d.ts
CHANGED
|
@@ -37,21 +37,33 @@ export type ProjectIdentityResolution = (ResolvedBase & {
|
|
|
37
37
|
kind: 'malformed';
|
|
38
38
|
detail: string;
|
|
39
39
|
path: string;
|
|
40
|
-
}) | (ResolvedBase & {
|
|
41
|
-
kind: 'nested';
|
|
42
|
-
parentIdentity?: ProjectIdentityFile;
|
|
43
|
-
}) | (ResolvedBase & {
|
|
44
|
-
kind: 'conflict';
|
|
45
|
-
rootIdentity: ProjectIdentityFile;
|
|
46
|
-
nestedIdentity: ProjectIdentityFile;
|
|
47
40
|
}) | {
|
|
48
41
|
kind: 'git_unavailable';
|
|
49
42
|
detail: string;
|
|
50
43
|
};
|
|
51
44
|
export declare function resolveRepositoryRoot(cwd: string): Promise<RepositoryRootResult>;
|
|
45
|
+
/**
|
|
46
|
+
* The project a working folder belongs to: the nearest `.mnemonik.json` above
|
|
47
|
+
* it. Git repositories are not project boundaries; a clone, submodule,
|
|
48
|
+
* subsystem or subproject inside a project belongs to that project unless it
|
|
49
|
+
* has its own identity file. Git has one part in identity: a linked worktree
|
|
50
|
+
* (and anything inside it without an identity file of its own below the
|
|
51
|
+
* worktree's top, nested clones and submodules included) belongs to the
|
|
52
|
+
* project of its main checkout; the worktree's own top-level copy of the
|
|
53
|
+
* identity file does not count.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveNearestProjectIdentity(cwd: string): Promise<ProjectIdentityResolution>;
|
|
56
|
+
/**
|
|
57
|
+
* Which project a folder is in. By default this is the rule every reader
|
|
58
|
+
* shares with the hooks (resolveNearestProjectIdentity). `namedRoot` and
|
|
59
|
+
* `selectedRoot` read exactly the folder given instead, for commands that make
|
|
60
|
+
* that folder a project on purpose; `selectedRoot` (folders ticked during
|
|
61
|
+
* install) also treats a configuration-only file as no identity, as the
|
|
62
|
+
* nearest-file walk always does.
|
|
63
|
+
*/
|
|
52
64
|
export declare function resolveProjectIdentity(cwd: string, options?: {
|
|
53
|
-
allowNestedInherit?: boolean;
|
|
54
65
|
selectedRoot?: boolean;
|
|
66
|
+
namedRoot?: boolean;
|
|
55
67
|
}): Promise<ProjectIdentityResolution>;
|
|
56
68
|
export {};
|
|
57
69
|
//# sourceMappingURL=repositoryRoot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repositoryRoot.d.ts","sourceRoot":"","sources":["../src/repositoryRoot.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;A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AAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAkGhD,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4CtF;AAmFD;;;;;;;;;GASG;AACH,wBAAsB,6BAA6B,CACjD,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,yBAAyB,CAAC,CAepC;AAwDD;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5D,OAAO,CAAC,yBAAyB,CAAC,CAKpC"}
|
package/dist/repositoryRoot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { lstat, readFile } from 'node:fs/promises';
|
|
1
|
+
import { lstat, readFile, realpath } from 'node:fs/promises';
|
|
2
2
|
import { execFile } from 'node:child_process';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { dirname, join, resolve } from 'node:path';
|
|
@@ -63,7 +63,7 @@ async function confirmedBoundaryAt(path) {
|
|
|
63
63
|
async function boundariesBetween(cwd, root) {
|
|
64
64
|
const boundaries = [];
|
|
65
65
|
let directory = cwd;
|
|
66
|
-
while (directory
|
|
66
|
+
while (!samePath(directory, root)) {
|
|
67
67
|
const boundary = await confirmedBoundaryAt(directory);
|
|
68
68
|
if (boundary)
|
|
69
69
|
boundaries.push(boundary);
|
|
@@ -86,38 +86,43 @@ async function containingRepository(root) {
|
|
|
86
86
|
directory = parent;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
catch (error) {
|
|
101
|
-
if (error.code === 'ENOENT')
|
|
102
|
-
return boundary.path;
|
|
103
|
-
throw error;
|
|
104
|
-
}
|
|
89
|
+
/**
|
|
90
|
+
* A path as the file system knows it, symlinks resolved, so it compares equal
|
|
91
|
+
* with the real paths of git's answers. A path that does not exist stays as given.
|
|
92
|
+
*/
|
|
93
|
+
async function canonicalPath(path) {
|
|
94
|
+
const absolute = resolve(path);
|
|
95
|
+
return realpath(absolute).catch(() => absolute);
|
|
96
|
+
}
|
|
97
|
+
/** Path equality; Windows paths compare without regard to case. */
|
|
98
|
+
function samePath(left, right) {
|
|
99
|
+
return process.platform === 'win32' ? left.toLowerCase() === right.toLowerCase() : left === right;
|
|
105
100
|
}
|
|
106
101
|
export async function resolveRepositoryRoot(cwd) {
|
|
107
|
-
const absoluteCwd =
|
|
102
|
+
const absoluteCwd = await canonicalPath(cwd);
|
|
108
103
|
try {
|
|
109
104
|
const { stdout } = await runGit(absoluteCwd, [
|
|
110
105
|
'rev-parse',
|
|
111
106
|
'--show-toplevel',
|
|
107
|
+
'--git-dir',
|
|
112
108
|
'--git-common-dir',
|
|
113
109
|
]);
|
|
114
|
-
const [rootLine, commonLine, ...extra] = stdout.trim().split(/\r?\n/);
|
|
115
|
-
if (!rootLine || !commonLine || extra.length) {
|
|
110
|
+
const [rootLine, gitDirLine, commonLine, ...extra] = stdout.trim().split(/\r?\n/);
|
|
111
|
+
if (!rootLine || !gitDirLine || !commonLine || extra.length) {
|
|
116
112
|
return { kind: 'git_unavailable', detail: 'git rev-parse returned an unexpected response' };
|
|
117
113
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
// git prints --git-dir and --git-common-dir relative to the directory it
|
|
115
|
+
// ran in (`../.git` from a subfolder) or absolute; every git version
|
|
116
|
+
// agrees on that. Real paths make them comparable with each other and
|
|
117
|
+
// with real paths from the file system.
|
|
118
|
+
const fromGit = (line) => canonicalPath(resolve(absoluteCwd, line));
|
|
119
|
+
const root = await fromGit(rootLine);
|
|
120
|
+
const gitDir = await fromGit(gitDirLine);
|
|
121
|
+
const commonDir = await fromGit(commonLine);
|
|
122
|
+
// Only a linked worktree keeps its own git directory apart from the common
|
|
123
|
+
// one. A submodule (`.git/modules/<name>`) and a `--separate-git-dir`
|
|
124
|
+
// checkout keep both in one place, wherever that is.
|
|
125
|
+
const isLinkedWorktree = !samePath(gitDir, commonDir);
|
|
121
126
|
const nested = await boundariesBetween(absoluteCwd, root);
|
|
122
127
|
if (!isLinkedWorktree && (await containingRepository(root))) {
|
|
123
128
|
const boundary = await boundaryAt(root);
|
|
@@ -140,14 +145,57 @@ export async function resolveRepositoryRoot(cwd) {
|
|
|
140
145
|
return { kind: 'git_unavailable', detail: failure.message };
|
|
141
146
|
}
|
|
142
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* The common git directory when `dir` is the top of a linked worktree: its
|
|
150
|
+
* `.git` is a file pointing at a git directory that has a `commondir`. A
|
|
151
|
+
* submodule's `.git` file points at `.git/modules/<name>`, which has none.
|
|
152
|
+
* Read from the files git writes, so it holds without a git command.
|
|
153
|
+
*/
|
|
154
|
+
async function linkedWorktreeCommonDir(dir) {
|
|
155
|
+
try {
|
|
156
|
+
if (!(await lstat(join(dir, '.git'))).isFile())
|
|
157
|
+
return undefined;
|
|
158
|
+
const pointer = /^gitdir:\s*(.+?)\s*$/im.exec(await readFile(join(dir, '.git'), 'utf8'))?.[1];
|
|
159
|
+
if (!pointer)
|
|
160
|
+
return undefined;
|
|
161
|
+
const gitDir = resolve(dir, pointer);
|
|
162
|
+
const common = (await readFile(join(gitDir, 'commondir'), 'utf8')).trim();
|
|
163
|
+
return common ? await canonicalPath(resolve(gitDir, common)) : undefined;
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The project folder of a linked worktree's main checkout: the first entry of
|
|
171
|
+
* `git worktree list --porcelain`. When that entry is a bare repository
|
|
172
|
+
* (`proj/.bare` with worktrees beside it), the project folder is the folder
|
|
173
|
+
* holding it, never the git directory itself. Without git, the folder holding
|
|
174
|
+
* the common git directory, which is the same answer for both layouts.
|
|
175
|
+
*/
|
|
176
|
+
async function mainCheckout(worktreeTop, commonDir) {
|
|
177
|
+
try {
|
|
178
|
+
const { stdout } = await runGit(worktreeTop, ['worktree', 'list', '--porcelain']);
|
|
179
|
+
const first = stdout.split(/\r?\n\r?\n/)[0] ?? '';
|
|
180
|
+
const path = /^worktree (.+)$/m.exec(first)?.[1];
|
|
181
|
+
if (path) {
|
|
182
|
+
const main = await canonicalPath(resolve(worktreeTop, path));
|
|
183
|
+
return /^bare$/m.test(first) ? dirname(main) : main;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
/* fall through */
|
|
188
|
+
}
|
|
189
|
+
return dirname(commonDir);
|
|
190
|
+
}
|
|
143
191
|
async function readPlainIdentity(start) {
|
|
144
|
-
const home =
|
|
192
|
+
const home = await canonicalPath(homedir());
|
|
145
193
|
let directory = start;
|
|
146
194
|
while (true) {
|
|
147
|
-
const result = await readIdentityFile(directory);
|
|
195
|
+
const result = await readIdentityFile(directory, { configurationOnlyAbsent: true });
|
|
148
196
|
if (result.kind !== 'absent')
|
|
149
197
|
return { root: directory, result };
|
|
150
|
-
if (directory
|
|
198
|
+
if (samePath(directory, home))
|
|
151
199
|
break;
|
|
152
200
|
const parent = dirname(directory);
|
|
153
201
|
if (parent === directory)
|
|
@@ -156,62 +204,102 @@ async function readPlainIdentity(start) {
|
|
|
156
204
|
}
|
|
157
205
|
return { root: start, result: { kind: 'absent' } };
|
|
158
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Walk up from `start` to the nearest identity file, stopping at the home
|
|
209
|
+
* folder (whose own file still counts). A configuration-only file (no
|
|
210
|
+
* `projectId`) is not an identity and the walk passes it. Reaching the top of a linked worktree
|
|
211
|
+
* first ends the walk there: the worktree belongs to its main checkout, and
|
|
212
|
+
* the copy of the identity file at its top does not count.
|
|
213
|
+
*/
|
|
214
|
+
async function nearestIdentity(start) {
|
|
215
|
+
const home = await canonicalPath(homedir());
|
|
216
|
+
let directory = start;
|
|
217
|
+
while (true) {
|
|
218
|
+
const commonDir = await linkedWorktreeCommonDir(directory);
|
|
219
|
+
if (commonDir)
|
|
220
|
+
return { worktreeTop: directory, commonDir };
|
|
221
|
+
const result = await readIdentityFile(directory, { configurationOnlyAbsent: true });
|
|
222
|
+
if (result.kind !== 'absent')
|
|
223
|
+
return { root: directory, result };
|
|
224
|
+
if (samePath(directory, home))
|
|
225
|
+
return undefined;
|
|
226
|
+
const parent = dirname(directory);
|
|
227
|
+
if (parent === directory)
|
|
228
|
+
return undefined;
|
|
229
|
+
directory = parent;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The project a working folder belongs to: the nearest `.mnemonik.json` above
|
|
234
|
+
* it. Git repositories are not project boundaries; a clone, submodule,
|
|
235
|
+
* subsystem or subproject inside a project belongs to that project unless it
|
|
236
|
+
* has its own identity file. Git has one part in identity: a linked worktree
|
|
237
|
+
* (and anything inside it without an identity file of its own below the
|
|
238
|
+
* worktree's top, nested clones and submodules included) belongs to the
|
|
239
|
+
* project of its main checkout; the worktree's own top-level copy of the
|
|
240
|
+
* identity file does not count.
|
|
241
|
+
*/
|
|
242
|
+
export async function resolveNearestProjectIdentity(cwd) {
|
|
243
|
+
const start = await canonicalPath(cwd);
|
|
244
|
+
const resolved = await resolveRepositoryRoot(start);
|
|
245
|
+
const repository = resolved.kind === 'git_unavailable' ? { kind: 'plain', root: start } : resolved;
|
|
246
|
+
const nested = repository.kind === 'git' ? repository.nested : [];
|
|
247
|
+
let found = await nearestIdentity(start);
|
|
248
|
+
if (found && 'worktreeTop' in found) {
|
|
249
|
+
found = await readPlainIdentity(await mainCheckout(found.worktreeTop, found.commonDir));
|
|
250
|
+
}
|
|
251
|
+
if (found) {
|
|
252
|
+
return shapedIdentity(found, await projectFolderRepository(found.root, repository), nested);
|
|
253
|
+
}
|
|
254
|
+
return { ...withBase(repository, repository.root, nested), kind: 'absent' };
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* The identity of exactly the folder named, for commands that create or link
|
|
258
|
+
* a project there on purpose, even inside another project. The top of a
|
|
259
|
+
* linked worktree stands for its main checkout.
|
|
260
|
+
*/
|
|
261
|
+
async function resolveNamedProjectIdentity(cwd, options) {
|
|
262
|
+
const start = await canonicalPath(cwd);
|
|
263
|
+
const resolved = await resolveRepositoryRoot(start);
|
|
264
|
+
const repository = resolved.kind === 'git_unavailable' ? { kind: 'plain', root: start } : resolved;
|
|
265
|
+
const commonDir = await linkedWorktreeCommonDir(start);
|
|
266
|
+
const root = commonDir ? await mainCheckout(start, commonDir) : start;
|
|
267
|
+
return shapedIdentity({ root, result: await readIdentityFile(root, options) }, await projectFolderRepository(root, repository), repository.kind === 'git' ? repository.nested : []);
|
|
268
|
+
}
|
|
269
|
+
function shapedIdentity(found, repository, nested) {
|
|
270
|
+
const base = withBase(repository, found.root, nested);
|
|
271
|
+
if (found.result.kind === 'ok')
|
|
272
|
+
return { ...base, ...found.result };
|
|
273
|
+
if (found.result.kind === 'unknown_version')
|
|
274
|
+
return { ...base, ...found.result, path: found.root };
|
|
275
|
+
if (found.result.kind === 'malformed')
|
|
276
|
+
return { ...base, ...found.result, path: found.root };
|
|
277
|
+
return { ...base, kind: 'absent' };
|
|
278
|
+
}
|
|
279
|
+
/** The project folder counts as a git repository only when it is the repository's top. */
|
|
280
|
+
async function projectFolderRepository(projectRoot, known) {
|
|
281
|
+
if (known.kind === 'git' && samePath(known.root, projectRoot))
|
|
282
|
+
return known;
|
|
283
|
+
const repository = await resolveRepositoryRoot(projectRoot);
|
|
284
|
+
if (repository.kind === 'git' && samePath(repository.root, projectRoot))
|
|
285
|
+
return repository;
|
|
286
|
+
return { kind: 'plain', root: projectRoot };
|
|
287
|
+
}
|
|
159
288
|
function withBase(repository, root, nested) {
|
|
160
289
|
return { root, repository, nested };
|
|
161
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Which project a folder is in. By default this is the rule every reader
|
|
293
|
+
* shares with the hooks (resolveNearestProjectIdentity). `namedRoot` and
|
|
294
|
+
* `selectedRoot` read exactly the folder given instead, for commands that make
|
|
295
|
+
* that folder a project on purpose; `selectedRoot` (folders ticked during
|
|
296
|
+
* install) also treats a configuration-only file as no identity, as the
|
|
297
|
+
* nearest-file walk always does.
|
|
298
|
+
*/
|
|
162
299
|
export async function resolveProjectIdentity(cwd, options = {}) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const repository = resolved.kind === 'git_unavailable' ? { kind: 'plain', root: resolve(cwd) } : resolved;
|
|
166
|
-
if (repository.kind === 'plain') {
|
|
167
|
-
const { root, result } = options.selectedRoot
|
|
168
|
-
? { root: repository.root, result: await readIdentityFile(repository.root, options) }
|
|
169
|
-
: await readPlainIdentity(repository.root);
|
|
170
|
-
const base = withBase(repository, root, []);
|
|
171
|
-
if (result.kind === 'ok')
|
|
172
|
-
return { ...base, ...result };
|
|
173
|
-
if (result.kind === 'unknown_version')
|
|
174
|
-
return { ...base, ...result, path: root };
|
|
175
|
-
if (result.kind === 'malformed')
|
|
176
|
-
return { ...base, ...result, path: root };
|
|
177
|
-
return { ...base, kind: 'absent' };
|
|
178
|
-
}
|
|
179
|
-
const ownRoot = repository.isLinkedWorktree ? dirname(repository.commonDir) : repository.root;
|
|
180
|
-
const outer = repository.isLinkedWorktree
|
|
181
|
-
? undefined
|
|
182
|
-
: await containingRepository(repository.root);
|
|
183
|
-
const own = await readIdentityFile(ownRoot, options);
|
|
184
|
-
if (!outer || options.selectedRoot || own.kind === 'ok') {
|
|
185
|
-
const base = withBase(repository, ownRoot, repository.nested);
|
|
186
|
-
if (own.kind === 'ok')
|
|
187
|
-
return { ...base, ...own };
|
|
188
|
-
if (own.kind === 'unknown_version')
|
|
189
|
-
return { ...base, ...own, path: ownRoot };
|
|
190
|
-
if (own.kind === 'malformed')
|
|
191
|
-
return { ...base, ...own, path: ownRoot };
|
|
192
|
-
return { ...base, kind: 'absent' };
|
|
193
|
-
}
|
|
194
|
-
const nested = repository.nested;
|
|
195
|
-
const parentRoot = await canonicalBoundaryRoot(outer);
|
|
196
|
-
const parent = await readIdentityFile(parentRoot);
|
|
197
|
-
const base = withBase(repository, parentRoot, nested);
|
|
198
|
-
if (own.kind === 'unknown_version')
|
|
199
|
-
return { ...base, ...own, path: ownRoot };
|
|
200
|
-
if (own.kind === 'malformed')
|
|
201
|
-
return { ...base, ...own, path: ownRoot };
|
|
202
|
-
if (parent.kind === 'unknown_version')
|
|
203
|
-
return { ...base, ...parent, path: parentRoot };
|
|
204
|
-
if (parent.kind === 'malformed')
|
|
205
|
-
return { ...base, ...parent, path: parentRoot };
|
|
206
|
-
if (!options.allowNestedInherit) {
|
|
207
|
-
return {
|
|
208
|
-
...base,
|
|
209
|
-
kind: 'nested',
|
|
210
|
-
...(parent.kind === 'ok' ? { parentIdentity: parent.identity } : {}),
|
|
211
|
-
};
|
|
300
|
+
if (options.selectedRoot || options.namedRoot) {
|
|
301
|
+
return resolveNamedProjectIdentity(cwd, { selectedRoot: options.selectedRoot });
|
|
212
302
|
}
|
|
213
|
-
|
|
214
|
-
return { ...base, kind: 'ok', identity: parent.identity };
|
|
215
|
-
return { ...base, kind: 'absent' };
|
|
303
|
+
return resolveNearestProjectIdentity(cwd);
|
|
216
304
|
}
|
|
217
305
|
//# sourceMappingURL=repositoryRoot.js.map
|