@context-forge/core 0.19.21 → 0.19.22

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.
Files changed (59) hide show
  1. package/dist/adoption/adoptionInputs.d.ts +1 -1
  2. package/dist/adoption/adoptionInputs.d.ts.map +1 -1
  3. package/dist/adoption/adoptionInputs.js +2 -1
  4. package/dist/adoption/adoptionInputs.js.map +1 -1
  5. package/dist/adoption/codebaseReference.d.ts +91 -0
  6. package/dist/adoption/codebaseReference.d.ts.map +1 -0
  7. package/dist/adoption/codebaseReference.js +145 -0
  8. package/dist/adoption/codebaseReference.js.map +1 -0
  9. package/dist/adoption/codebaseReferenceText.d.ts +24 -0
  10. package/dist/adoption/codebaseReferenceText.d.ts.map +1 -0
  11. package/dist/adoption/codebaseReferenceText.js +61 -0
  12. package/dist/adoption/codebaseReferenceText.js.map +1 -0
  13. package/dist/adoption/index.d.ts +2 -0
  14. package/dist/adoption/index.d.ts.map +1 -1
  15. package/dist/adoption/index.js +2 -0
  16. package/dist/adoption/index.js.map +1 -1
  17. package/dist/docs-map/docsMapError.d.ts +10 -1
  18. package/dist/docs-map/docsMapError.d.ts.map +1 -1
  19. package/dist/docs-map/docsMapError.js +11 -2
  20. package/dist/docs-map/docsMapError.js.map +1 -1
  21. package/dist/docs-map/docsMapFile.d.ts +24 -1
  22. package/dist/docs-map/docsMapFile.d.ts.map +1 -1
  23. package/dist/docs-map/docsMapFile.js +27 -11
  24. package/dist/docs-map/docsMapFile.js.map +1 -1
  25. package/dist/docs-map/index.d.ts +2 -2
  26. package/dist/docs-map/index.d.ts.map +1 -1
  27. package/dist/docs-map/index.js +2 -2
  28. package/dist/docs-map/index.js.map +1 -1
  29. package/dist/guides/guideMinimum.d.ts +1 -1
  30. package/dist/guides/guideMinimum.d.ts.map +1 -1
  31. package/dist/guides/guideMinimum.js +1 -1
  32. package/dist/guides/guideMinimum.js.map +1 -1
  33. package/dist/schema/projectSchema.d.ts +7 -0
  34. package/dist/schema/projectSchema.d.ts.map +1 -1
  35. package/dist/schema/projectSchema.js +5 -0
  36. package/dist/schema/projectSchema.js.map +1 -1
  37. package/dist/services/ContextIntegrator.d.ts +18 -2
  38. package/dist/services/ContextIntegrator.d.ts.map +1 -1
  39. package/dist/services/ContextIntegrator.js +36 -7
  40. package/dist/services/ContextIntegrator.js.map +1 -1
  41. package/dist/services/ContextTemplateEngine.d.ts.map +1 -1
  42. package/dist/services/ContextTemplateEngine.js +10 -0
  43. package/dist/services/ContextTemplateEngine.js.map +1 -1
  44. package/dist/services/CoreServiceFactory.d.ts.map +1 -1
  45. package/dist/services/CoreServiceFactory.js +2 -1
  46. package/dist/services/CoreServiceFactory.js.map +1 -1
  47. package/dist/services/codebaseReferenceResolver.d.ts +4 -0
  48. package/dist/services/codebaseReferenceResolver.d.ts.map +1 -0
  49. package/dist/services/codebaseReferenceResolver.js +5 -0
  50. package/dist/services/codebaseReferenceResolver.js.map +1 -0
  51. package/dist/services/constants.d.ts +8 -0
  52. package/dist/services/constants.d.ts.map +1 -1
  53. package/dist/services/constants.js +8 -0
  54. package/dist/services/constants.js.map +1 -1
  55. package/dist/types/context.d.ts +3 -0
  56. package/dist/types/context.d.ts.map +1 -1
  57. package/dist/types/project.d.ts +3 -1
  58. package/dist/types/project.d.ts.map +1 -1
  59. package/package.json +1 -1
@@ -16,7 +16,7 @@ export declare function toRootRelative(root: string, absolutePath: string): stri
16
16
  */
17
17
  export declare function readAdoptionArtifacts(root: string, facts?: PlanningFacts): Promise<AdoptionArtifacts>;
18
18
  /** The guide's context-profile variable that marks a prompt as taking a comprehension doc (D10: the guide's name). */
19
- export declare const COMPREHENSION_PROFILE_VARIABLE = "fileComprehension";
19
+ export declare const COMPREHENSION_PROFILE_VARIABLE: "fileComprehension";
20
20
  export declare const ADOPTION_INPUTS_HEADING = "## Adoption Inputs";
21
21
  export declare const ADOPTION_INPUT_LABELS: {
22
22
  readonly comprehension: "Codebase comprehension";
@@ -1 +1 @@
1
- {"version":3,"file":"adoptionInputs.d.ts","sourceRoot":"","sources":["../../src/adoption/adoptionInputs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQ3G;AAED,sHAAsH;AACtH,eAAO,MAAM,8BAA8B,sBAAsB,CAAC;AAElE,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAC5D,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AACX,eAAO,MAAM,yBAAyB,qDAAqD,CAAC;AAC5F,eAAO,MAAM,eAAe,SAAS,CAAC;AAStC;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,iBAAiB,EAAE,MAAM,GAAG,IAAI,EAChC,SAAS,EAAE,iBAAiB,GAC3B,MAAM,CAcR"}
1
+ {"version":3,"file":"adoptionInputs.d.ts","sourceRoot":"","sources":["../../src/adoption/adoptionInputs.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAQ3G;AAED,sHAAsH;AACtH,eAAO,MAAM,8BAA8B,qBAA6C,CAAC;AAEzF,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAC5D,eAAO,MAAM,qBAAqB;;;;;CAKxB,CAAC;AACX,eAAO,MAAM,yBAAyB,qDAAqD,CAAC;AAC5F,eAAO,MAAM,eAAe,SAAS,CAAC;AAStC;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,iBAAiB,EAAE,MAAM,GAAG,IAAI,EAChC,SAAS,EAAE,iBAAiB,GAC3B,MAAM,CAcR"}
@@ -2,6 +2,7 @@
2
2
  // adoption, reported as root-relative paths so consumers need not know cf's file names. Read-only.
3
3
  import { isAbsolute, relative, sep } from 'node:path';
4
4
  import { resolveConceptPath } from '../introspection/parsers/projectGuideFile.js';
5
+ import { CODEBASE_REFERENCE_VARIABLES } from '../services/constants.js';
5
6
  import { readPlanningFacts } from './planningFacts.js';
6
7
  /**
7
8
  * A path relative to `root` with `/` separators (D3). A path outside the root keeps its climbing
@@ -25,7 +26,7 @@ export async function readAdoptionArtifacts(root, facts) {
25
26
  };
26
27
  }
27
28
  /** The guide's context-profile variable that marks a prompt as taking a comprehension doc (D10: the guide's name). */
28
- export const COMPREHENSION_PROFILE_VARIABLE = 'fileComprehension';
29
+ export const COMPREHENSION_PROFILE_VARIABLE = CODEBASE_REFERENCE_VARIABLES.comprehension;
29
30
  export const ADOPTION_INPUTS_HEADING = '## Adoption Inputs';
30
31
  export const ADOPTION_INPUT_LABELS = {
31
32
  comprehension: 'Codebase comprehension',
@@ -1 +1 @@
1
- {"version":3,"file":"adoptionInputs.js","sourceRoot":"","sources":["../../src/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AC,KAAa,EAAE,KAAoB,EAAU,EAAE,CAAC,KAAK,KAAK,KAAK,KAAK,IAAI,eAAe,EAAE,CAAC;IAC3G,MAAM,aAAa,GACjB,iBAAiB,KAAK,IAAI;QACxB,CAAC,CAAC,KAAK,yBAAyB,EAAE;QAClC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,aAAa,EAAE,WAAW,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACzF,MAAM,OAAO,GAAG,SAAS,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7G,OAAO;QACL,uBAAuB;QACvB,aAAa;QACb,OAAO,CAAC,qBAAqB,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC;QACzD,OAAO,CAAC,qBAAqB,CAAC,mBAAmB,EAAE,OAAO,CAAC;QAC3D,OAAO,CAAC,qBAAqB,CAAC,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,CAAC;KAC9E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,91 @@
1
+ /** Why a path failed the check. Callers map the reason to their own error type. */
2
+ export declare const PATH_CHECK_REASONS: {
3
+ readonly missing: "missing";
4
+ readonly directory: "directory";
5
+ readonly outsideRoot: "outside-root";
6
+ };
7
+ export type PathCheckReason = (typeof PATH_CHECK_REASONS)[keyof typeof PATH_CHECK_REASONS];
8
+ /** User-visible wording per reason. The argument is the resolved absolute path. */
9
+ export declare const PATH_CHECK_MESSAGES: Record<PathCheckReason, (resolved: string) => string>;
10
+ /** Raised by the path check; `reason` says which rule failed. */
11
+ export declare class PathCheckError extends Error {
12
+ readonly reason: PathCheckReason;
13
+ constructor(reason: PathCheckReason, resolved: string);
14
+ }
15
+ export interface PathCheckOptions {
16
+ /** When true, a path that resolves outside the root is rejected. */
17
+ requireInsideRoot: boolean;
18
+ }
19
+ /**
20
+ * Resolves `input` against the project root. The path must exist and be a file; with
21
+ * `requireInsideRoot` it must also lie inside the root, compared by real path so a symlinked
22
+ * spelling of the root (macOS `/var` vs `/private/var`) still counts as inside. cf never reads
23
+ * the file: it only names the path to an agent that can already read the disk.
24
+ * @returns the absolute resolved path
25
+ */
26
+ export declare function resolveComprehensionPath(root: string, input: string, options: PathCheckOptions): string;
27
+ /**
28
+ * Setter-side normalization for a path-valued field: `""` clears the field; any other input is
29
+ * checked (inside the root) and returned relative to `root` with `/` separators.
30
+ */
31
+ export declare function normalizePathFieldValue(root: string, input: string): string;
32
+ /** Which comprehension state the build reports (D5). */
33
+ export declare const COMPREHENSION_FACT: {
34
+ readonly None: "none";
35
+ readonly Present: "present";
36
+ readonly Missing: "missing";
37
+ readonly NotReadable: "not-readable";
38
+ };
39
+ /** Which docs map state the build reports (D5). */
40
+ export declare const DOCS_MAP_FACT: {
41
+ readonly None: "none";
42
+ readonly Current: "current";
43
+ readonly OutOfDate: "out-of-date";
44
+ readonly CannotCheck: "cannot-check";
45
+ };
46
+ /** Structured facts only: the wording lives in the section renderer. Paths are root-relative with `/`. */
47
+ export type ComprehensionFact = {
48
+ kind: typeof COMPREHENSION_FACT.None;
49
+ } | {
50
+ kind: typeof COMPREHENSION_FACT.Present;
51
+ path: string;
52
+ } | {
53
+ kind: typeof COMPREHENSION_FACT.Missing;
54
+ path: string;
55
+ reason: string;
56
+ } | {
57
+ kind: typeof COMPREHENSION_FACT.NotReadable;
58
+ path: string;
59
+ reason: string;
60
+ };
61
+ export type DocsMapFact = {
62
+ kind: typeof DOCS_MAP_FACT.None;
63
+ } | {
64
+ kind: typeof DOCS_MAP_FACT.Current;
65
+ path: string;
66
+ } | {
67
+ kind: typeof DOCS_MAP_FACT.OutOfDate;
68
+ path: string;
69
+ } | {
70
+ kind: typeof DOCS_MAP_FACT.CannotCheck;
71
+ /** Null when the project name cannot form a map path at all. */
72
+ path: string | null;
73
+ reason: string;
74
+ /** True when the map's markers are the problem, so fixing them is the remedy. */
75
+ markers: boolean;
76
+ };
77
+ /** Which of the two build variables the active profile lists. */
78
+ export interface ListedReferences {
79
+ comprehension: boolean;
80
+ docsMap: boolean;
81
+ }
82
+ export interface CodebaseReferenceFacts {
83
+ comprehension?: ComprehensionFact;
84
+ docsMap?: DocsMapFact;
85
+ }
86
+ /**
87
+ * The comprehension doc and docs map facts for the variables the profile lists (D5). Reads only:
88
+ * the compare step never writes. Failures that D5 names become facts; any other error propagates.
89
+ */
90
+ export declare function readCodebaseReference(root: string, projectName: string, fileComprehension: string, listed: ListedReferences): Promise<CodebaseReferenceFacts>;
91
+ //# sourceMappingURL=codebaseReference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codebaseReference.d.ts","sourceRoot":"","sources":["../../src/adoption/codebaseReference.ts"],"names":[],"mappings":"AAcA,mFAAmF;AACnF,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE3F,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAIrF,CAAC;AAEF,iEAAiE;AACjE,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM;CAKtD;AAED,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAQD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAcvG;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAA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iBAAiB,CAAC;IAClC,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB;AAiDD;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,MAAM,EACzB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,sBAAsB,CAAC,CAMjC"}
@@ -0,0 +1,145 @@
1
+ // Path check for the codebase comprehension doc, shared by `cf prompt get --comprehension`
2
+ // and the `fileComprehension` setters (slice 274, D3).
3
+ import * as fs from 'node:fs';
4
+ import * as path from 'node:path';
5
+ import { isEnoent, isFsError } from '../detection/pathPresent.js';
6
+ import { DOCS_MAP_ERROR_KIND, DOCS_MAP_STATE, DocsMapError, compareDocsMap, docsMapPath, } from '../docs-map/index.js';
7
+ import { toRootRelative } from './adoptionInputs.js';
8
+ /** Why a path failed the check. Callers map the reason to their own error type. */
9
+ export const PATH_CHECK_REASONS = {
10
+ missing: 'missing',
11
+ directory: 'directory',
12
+ outsideRoot: 'outside-root',
13
+ };
14
+ /** User-visible wording per reason. The argument is the resolved absolute path. */
15
+ export const PATH_CHECK_MESSAGES = {
16
+ [PATH_CHECK_REASONS.missing]: (resolved) => `path does not exist: ${resolved}`,
17
+ [PATH_CHECK_REASONS.directory]: (resolved) => `path is a directory, not a file: ${resolved}`,
18
+ [PATH_CHECK_REASONS.outsideRoot]: (resolved) => `path is outside the project root: ${resolved}`,
19
+ };
20
+ /** Raised by the path check; `reason` says which rule failed. */
21
+ export class PathCheckError extends Error {
22
+ reason;
23
+ constructor(reason, resolved) {
24
+ super(PATH_CHECK_MESSAGES[reason](resolved));
25
+ this.name = 'PathCheckError';
26
+ this.reason = reason;
27
+ }
28
+ }
29
+ /** True when `resolved` is `root` or lies beneath it. */
30
+ function isInsideRoot(root, resolved) {
31
+ const relative = path.relative(root, resolved);
32
+ return relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
33
+ }
34
+ /**
35
+ * Resolves `input` against the project root. The path must exist and be a file; with
36
+ * `requireInsideRoot` it must also lie inside the root, compared by real path so a symlinked
37
+ * spelling of the root (macOS `/var` vs `/private/var`) still counts as inside. cf never reads
38
+ * the file: it only names the path to an agent that can already read the disk.
39
+ * @returns the absolute resolved path
40
+ */
41
+ export function resolveComprehensionPath(root, input, options) {
42
+ const resolved = path.resolve(root, input);
43
+ let stats;
44
+ try {
45
+ stats = fs.statSync(resolved);
46
+ }
47
+ catch (error) {
48
+ if (!isEnoent(error))
49
+ throw error;
50
+ throw new PathCheckError(PATH_CHECK_REASONS.missing, resolved);
51
+ }
52
+ if (stats.isDirectory())
53
+ throw new PathCheckError(PATH_CHECK_REASONS.directory, resolved);
54
+ if (options.requireInsideRoot && !isInsideRoot(fs.realpathSync(root), fs.realpathSync(resolved))) {
55
+ throw new PathCheckError(PATH_CHECK_REASONS.outsideRoot, resolved);
56
+ }
57
+ return resolved;
58
+ }
59
+ /**
60
+ * Setter-side normalization for a path-valued field: `""` clears the field; any other input is
61
+ * checked (inside the root) and returned relative to `root` with `/` separators.
62
+ */
63
+ export function normalizePathFieldValue(root, input) {
64
+ if (input === '')
65
+ return '';
66
+ const resolved = resolveComprehensionPath(root, input, { requireInsideRoot: true });
67
+ return toRootRelative(fs.realpathSync(root), fs.realpathSync(resolved));
68
+ }
69
+ /** Which comprehension state the build reports (D5). */
70
+ export const COMPREHENSION_FACT = {
71
+ None: 'none',
72
+ Present: 'present',
73
+ Missing: 'missing',
74
+ NotReadable: 'not-readable',
75
+ };
76
+ /** Which docs map state the build reports (D5). */
77
+ export const DOCS_MAP_FACT = {
78
+ None: 'none',
79
+ Current: 'current',
80
+ OutOfDate: 'out-of-date',
81
+ CannotCheck: 'cannot-check',
82
+ };
83
+ const NOT_A_FILE_REASON = 'is a directory, not a file';
84
+ // The stored path is trusted: the setters keep it inside the root, and cf only stats it. A
85
+ // hand-edited value outside the root is reported like any other path.
86
+ async function readComprehensionFact(root, fileComprehension) {
87
+ if (fileComprehension === '')
88
+ return { kind: COMPREHENSION_FACT.None };
89
+ const resolved = path.resolve(root, fileComprehension);
90
+ const relative = toRootRelative(root, resolved);
91
+ try {
92
+ const stats = await fs.promises.stat(resolved);
93
+ if (stats.isDirectory())
94
+ return { kind: COMPREHENSION_FACT.NotReadable, path: relative, reason: NOT_A_FILE_REASON };
95
+ await fs.promises.access(resolved, fs.constants.R_OK);
96
+ return { kind: COMPREHENSION_FACT.Present, path: relative };
97
+ }
98
+ catch (error) {
99
+ // Filesystem failures are reported as facts; anything else is a bug and propagates.
100
+ if (!isFsError(error))
101
+ throw error;
102
+ if (error.code === 'ENOENT')
103
+ return { kind: COMPREHENSION_FACT.Missing, path: relative, reason: error.code };
104
+ return { kind: COMPREHENSION_FACT.NotReadable, path: relative, reason: error.code };
105
+ }
106
+ }
107
+ async function readDocsMapFact(root, projectName) {
108
+ let mapPath = null;
109
+ try {
110
+ mapPath = toRootRelative(root, docsMapPath(root, projectName));
111
+ const comparison = await compareDocsMap(root, projectName);
112
+ if (comparison.state === DOCS_MAP_STATE.Absent)
113
+ return { kind: DOCS_MAP_FACT.None };
114
+ const kind = comparison.state === DOCS_MAP_STATE.Current ? DOCS_MAP_FACT.Current : DOCS_MAP_FACT.OutOfDate;
115
+ return { kind, path: mapPath };
116
+ }
117
+ catch (error) {
118
+ // The docs map reports its own failures as DocsMapError; raw filesystem errors can still
119
+ // escape discovery. Both degrade to a fact. Anything else is a bug and propagates.
120
+ if (error instanceof DocsMapError) {
121
+ return {
122
+ kind: DOCS_MAP_FACT.CannotCheck,
123
+ path: mapPath,
124
+ reason: error.reason,
125
+ markers: error.kind === DOCS_MAP_ERROR_KIND.Markers,
126
+ };
127
+ }
128
+ if (isFsError(error)) {
129
+ return { kind: DOCS_MAP_FACT.CannotCheck, path: mapPath, reason: error.code, markers: false };
130
+ }
131
+ throw error;
132
+ }
133
+ }
134
+ /**
135
+ * The comprehension doc and docs map facts for the variables the profile lists (D5). Reads only:
136
+ * the compare step never writes. Failures that D5 names become facts; any other error propagates.
137
+ */
138
+ export async function readCodebaseReference(root, projectName, fileComprehension, listed) {
139
+ const [comprehension, docsMap] = await Promise.all([
140
+ listed.comprehension ? readComprehensionFact(root, fileComprehension) : undefined,
141
+ listed.docsMap ? readDocsMapFact(root, projectName) : undefined,
142
+ ]);
143
+ return { comprehension, docsMap };
144
+ }
145
+ //# sourceMappingURL=codebaseReference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codebaseReference.js","sourceRoot":"","sources":["../../src/adoption/codebaseReference.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,uDAAuD;AACvD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,cAAc;CACnB,CAAC;AAIX,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAA0D;IACxF,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,wBAAwB,QAAQ,EAAE;IAC9E,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,oCAAoC,QAAQ,EAAE;IAC5F,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,qCAAqC,QAAQ,EAAE;CAChG,CAAC;AAEF,iEAAiE;AACjE,MAAM,OAAO,cAAe,SAAQ,KAAK;I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CAAC;AACpC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type CodebaseReferenceFacts } from './codebaseReference.js';
2
+ export declare const CODEBASE_REFERENCE_HEADING = "### Codebase Reference";
3
+ export declare const CODEBASE_REFERENCE_LABELS: {
4
+ readonly comprehension: "Codebase comprehension";
5
+ readonly docsMap: "Docs map";
6
+ };
7
+ /** The docs map is cf's own artifact, so its remedies name cf's own command. */
8
+ export declare const DOCS_MAP_COMMAND = "cf docs map";
9
+ export declare const COMPREHENSION_NONE = "none registered.";
10
+ export declare const DOCS_MAP_NONE = "none. Run `cf docs map` to create it.";
11
+ export declare const DOCS_MAP_CURRENT = "current";
12
+ export declare const DOCS_MAP_OUT_OF_DATE = "out of date: run `cf docs map` to refresh";
13
+ export declare const DOCS_MAP_FIX_MARKERS = "fix the markers, then run `cf docs map`";
14
+ /**
15
+ * D7: names the action without naming a squadron command. Appended only to the missing and
16
+ * not-readable lines, never to the "none registered" line.
17
+ */
18
+ export declare const COMPREHENSION_REFRESH_SENTENCE = "Refresh it through squadron, which registers the new path with `cf set comprehension`.";
19
+ /**
20
+ * The section text: the heading, then one line per fact, comprehension first. Returns `''` when
21
+ * there are no facts, so an unlisted pair of variables adds nothing to the build.
22
+ */
23
+ export declare function renderCodebaseReference(facts: CodebaseReferenceFacts): string;
24
+ //# sourceMappingURL=codebaseReferenceText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codebaseReferenceText.d.ts","sourceRoot":"","sources":["../../src/adoption/codebaseReferenceText.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,sBAAsB,EAG5B,MAAM,wBAAwB,CAAC;AAEhC,eAAO,MAAM,0BAA0B,2BAA2B,CAAC;AAEnE,eAAO,MAAM,yBAAyB;;;CAG5B,CAAC;AAEX,gFAAgF;AAChF,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C,eAAO,MAAM,kBAAkB,qBAAqB,CAAC;AACrD,eAAO,MAAM,aAAa,0CAAoD,CAAC;AAC/E,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,oBAAoB,8CAAwD,CAAC;AAC1F,eAAO,MAAM,oBAAoB,4CAAsD,CAAC;AAExF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,2FAC+C,CAAC;AA8B3F;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAS7E"}
@@ -0,0 +1,61 @@
1
+ // Wording and rendering of the `### Codebase Reference` build section (slice 274, D5-D7).
2
+ // Facts come from `readCodebaseReference`; this file turns them into text and nothing else.
3
+ import { COMPREHENSION_FACT, DOCS_MAP_FACT, } from './codebaseReference.js';
4
+ export const CODEBASE_REFERENCE_HEADING = '### Codebase Reference';
5
+ export const CODEBASE_REFERENCE_LABELS = {
6
+ comprehension: 'Codebase comprehension',
7
+ docsMap: 'Docs map',
8
+ };
9
+ /** The docs map is cf's own artifact, so its remedies name cf's own command. */
10
+ export const DOCS_MAP_COMMAND = 'cf docs map';
11
+ export const COMPREHENSION_NONE = 'none registered.';
12
+ export const DOCS_MAP_NONE = `none. Run \`${DOCS_MAP_COMMAND}\` to create it.`;
13
+ export const DOCS_MAP_CURRENT = 'current';
14
+ export const DOCS_MAP_OUT_OF_DATE = `out of date: run \`${DOCS_MAP_COMMAND}\` to refresh`;
15
+ export const DOCS_MAP_FIX_MARKERS = `fix the markers, then run \`${DOCS_MAP_COMMAND}\``;
16
+ /**
17
+ * D7: names the action without naming a squadron command. Appended only to the missing and
18
+ * not-readable lines, never to the "none registered" line.
19
+ */
20
+ export const COMPREHENSION_REFRESH_SENTENCE = 'Refresh it through squadron, which registers the new path with `cf set comprehension`.';
21
+ function comprehensionLine(fact) {
22
+ switch (fact.kind) {
23
+ case COMPREHENSION_FACT.None:
24
+ return COMPREHENSION_NONE;
25
+ case COMPREHENSION_FACT.Present:
26
+ return fact.path;
27
+ case COMPREHENSION_FACT.Missing:
28
+ return `${fact.path} (missing: ${fact.reason}). ${COMPREHENSION_REFRESH_SENTENCE}`;
29
+ case COMPREHENSION_FACT.NotReadable:
30
+ return `${fact.path} (not readable: ${fact.reason}). ${COMPREHENSION_REFRESH_SENTENCE}`;
31
+ }
32
+ }
33
+ function docsMapLine(fact) {
34
+ switch (fact.kind) {
35
+ case DOCS_MAP_FACT.None:
36
+ return DOCS_MAP_NONE;
37
+ case DOCS_MAP_FACT.Current:
38
+ return `${fact.path} (${DOCS_MAP_CURRENT})`;
39
+ case DOCS_MAP_FACT.OutOfDate:
40
+ return `${fact.path} (${DOCS_MAP_OUT_OF_DATE})`;
41
+ case DOCS_MAP_FACT.CannotCheck: {
42
+ const detail = fact.markers ? `${fact.reason}; ${DOCS_MAP_FIX_MARKERS}` : fact.reason;
43
+ return fact.path === null ? `cannot check: ${detail}` : `${fact.path} (cannot check: ${detail})`;
44
+ }
45
+ }
46
+ }
47
+ /**
48
+ * The section text: the heading, then one line per fact, comprehension first. Returns `''` when
49
+ * there are no facts, so an unlisted pair of variables adds nothing to the build.
50
+ */
51
+ export function renderCodebaseReference(facts) {
52
+ const lines = [];
53
+ if (facts.comprehension) {
54
+ lines.push(`${CODEBASE_REFERENCE_LABELS.comprehension}: ${comprehensionLine(facts.comprehension)}`);
55
+ }
56
+ if (facts.docsMap) {
57
+ lines.push(`${CODEBASE_REFERENCE_LABELS.docsMap}: ${docsMapLine(facts.docsMap)}`);
58
+ }
59
+ return lines.length === 0 ? '' : [CODEBASE_REFERENCE_HEADING, ...lines].join('\n');
60
+ }
61
+ //# sourceMappingURL=codebaseReferenceText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codebaseReferenceText.js","sourceRoot":"","sources":["../../src/adoption/codebaseReferenceText.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,4FAA4F;AAC5F,OAAO,EACL,kBAAkB,EAClB,aAAa,GAId,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAEnE,M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C,KAAK,aAAa,CAAC,SAAS;YAC1B,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,oBAAoB,GAAG,CAAC;QAClD,KAAK,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,KAAK,oBAAoB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;YACtF,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,iBAAiB,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,mBAAmB,MAAM,GAAG,CAAC;QACnG,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAA6B;IACnE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,aAAa,KAAK,iBAAiB,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACtG,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,OAAO,KAAK,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,0BAA0B,EAAE,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrF,CAAC"}
@@ -4,6 +4,8 @@ export * from './adoptionOutcome.js';
4
4
  export * from './planningFacts.js';
5
5
  export * from './adoptionLines.js';
6
6
  export * from './adoptionInputs.js';
7
+ export * from './codebaseReference.js';
8
+ export * from './codebaseReferenceText.js';
7
9
  export * from './detectionReport.js';
8
10
  export * from './projectDetection.js';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adoption/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adoption/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
@@ -4,6 +4,8 @@ export * from './adoptionOutcome.js';
4
4
  export * from './planningFacts.js';
5
5
  export * from './adoptionLines.js';
6
6
  export * from './adoptionInputs.js';
7
+ export * from './codebaseReference.js';
8
+ export * from './codebaseReferenceText.js';
7
9
  export * from './detectionReport.js';
8
10
  export * from './projectDetection.js';
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adoption/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adoption/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
@@ -1,7 +1,16 @@
1
+ /** What went wrong, so callers choose a remedy without matching on message text. */
2
+ export declare const DOCS_MAP_ERROR_KIND: {
3
+ /** The map's managed block is absent or broken: fixing the markers is the remedy. */
4
+ readonly Markers: "markers";
5
+ /** Any other failure: unreadable files, an unusable project name. */
6
+ readonly Other: "other";
7
+ };
8
+ export type DocsMapErrorKind = (typeof DOCS_MAP_ERROR_KIND)[keyof typeof DOCS_MAP_ERROR_KIND];
1
9
  export declare class DocsMapError extends Error {
2
10
  readonly path: string;
3
11
  readonly reason: string;
4
- constructor(path: string, reason: string);
12
+ readonly kind: DocsMapErrorKind;
13
+ constructor(path: string, reason: string, kind: DocsMapErrorKind);
5
14
  }
6
15
  /**
7
16
  * Wrap a filesystem failure as a DocsMapError naming the path and system code.
@@ -1 +1 @@
1
- {"version":3,"file":"docsMapError.d.ts","sourceRoot":"","sources":["../../src/docs-map/docsMapError.ts"],"names":[],"mappings":"AAIA,qBAAa,YAAa,SAAQ,KAAK;IAEnC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAK1B;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAGjF"}
1
+ {"version":3,"file":"docsMapError.d.ts","sourceRoot":"","sources":["../../src/docs-map/docsMapError.ts"],"names":[],"mappings":"AAIA,oFAAoF;AACpF,eAAO,MAAM,mBAAmB;IAC9B,qFAAqF;;IAErF,qEAAqE;;CAE7D,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAE9F,qBAAa,YAAa,SAAQ,KAAK;IAEnC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,gBAAgB;gBAFtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,gBAAgB;CAKlC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAGjF"}
@@ -1,13 +1,22 @@
1
1
  // Failure of the docs map (slice 267): carries the path and the reason, and names both.
2
2
  // Lives in its own file so discovery and the map writer can both import it without a cycle.
3
3
  import { isFsError } from '../detection/pathPresent.js';
4
+ /** What went wrong, so callers choose a remedy without matching on message text. */
5
+ export const DOCS_MAP_ERROR_KIND = {
6
+ /** The map's managed block is absent or broken: fixing the markers is the remedy. */
7
+ Markers: 'markers',
8
+ /** Any other failure: unreadable files, an unusable project name. */
9
+ Other: 'other',
10
+ };
4
11
  export class DocsMapError extends Error {
5
12
  path;
6
13
  reason;
7
- constructor(path, reason) {
14
+ kind;
15
+ constructor(path, reason, kind) {
8
16
  super(`Docs map: ${reason} (${path})`);
9
17
  this.path = path;
10
18
  this.reason = reason;
19
+ this.kind = kind;
11
20
  this.name = 'DocsMapError';
12
21
  }
13
22
  }
@@ -18,6 +27,6 @@ export class DocsMapError extends Error {
18
27
  export function wrapFsError(path, action, error) {
19
28
  if (!isFsError(error))
20
29
  return error;
21
- return new DocsMapError(path, `cannot ${action}: ${error.code}`);
30
+ return new DocsMapError(path, `cannot ${action}: ${error.code}`, DOCS_MAP_ERROR_KIND.Other);
22
31
  }
23
32
  //# sourceMappingURL=docsMapError.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"docsMapError.js","sourceRoot":"","sources":["../../src/docs-map/docsMapError.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,4FAA4F;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE1B;IACA;IAFX,YACW,IAAY,EACZ,MAAc;QAEvB,KAAK,CAAC,aAAa,MAAM,KAAK,IAAI,GAAG,CAAC,CAAC;QAH9B,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QAGvB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,MAAc,EAAE,KAAc;IACtE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,UAAU,MAAM,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AACnE,CAAC"}
1
+ {"version":3,"file":"docsMapError.js","sourceRoot":"","sources":["../../src/docs-map/docsMapError.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,4FAA4F;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,oFAAoF;AACpF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,qFAAqF;IACrF,OAAO,EAAE,SAAS;IAClB,qEAAqE;IACrE,KAAK,EAAE,OAAO;CACN,CAAC;AAIX,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE1B;IACA;IACA;IAHX,YACW,IAAY,EACZ,MAAc,EACd,IAAsB;QAE/B,KAAK,CAAC,aAAa,MAAM,KAAK,IAAI,GAAG,CAAC,CAAC;QAJ9B,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAkB;QAG/B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,MAAc,EAAE,KAAc;IACtE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,UAAU,MAAM,KAAK,KAAK,CAAC,IAAI,EAAE,EAAE,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAC9F,CAAC"}
@@ -19,6 +19,29 @@ export interface DocsMapResult {
19
19
  }
20
20
  /** The canonical map path. No pattern search: a renamed project gets a new map (D1). */
21
21
  export declare function docsMapPath(root: string, projectName: string): string;
22
- /** Write or refresh the project's docs map. Discovery runs first, so a discovery error leaves any map untouched. */
22
+ /** Whether the map file matches what `cf docs map` would write now. */
23
+ export declare const DOCS_MAP_STATE: {
24
+ readonly Absent: "absent";
25
+ readonly Current: "current";
26
+ readonly OutOfDate: "out-of-date";
27
+ };
28
+ export type DocsMapState = (typeof DOCS_MAP_STATE)[keyof typeof DOCS_MAP_STATE];
29
+ export interface DocsMapComparison {
30
+ path: string;
31
+ state: DocsMapState;
32
+ adrs: number;
33
+ docs: number;
34
+ skippedSymlinks: string[];
35
+ /** The text a write would produce, in `encoding`. For a current map it equals the file. */
36
+ content: string;
37
+ encoding: BufferEncoding;
38
+ }
39
+ /**
40
+ * Discover, render and compare against the map on disk, without writing (slice 274, D5). Shared
41
+ * by `writeDocsMap` and the build's freshness check. Discovery runs first, so a discovery error
42
+ * surfaces before any map is read; broken or absent markers raise `DocsMapError`.
43
+ */
44
+ export declare function compareDocsMap(root: string, projectName: string): Promise<DocsMapComparison>;
45
+ /** Write or refresh the project's docs map. A discovery error leaves any map untouched. */
23
46
  export declare function writeDocsMap(root: string, projectName: string): Promise<DocsMapResult>;
24
47
  //# sourceMappingURL=docsMapFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"docsMapFile.d.ts","sourceRoot":"","sources":["../../src/docs-map/docsMapFile.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,+BAA+B,CAAC;AAC3D,eAAO,MAAM,YAAY,6BAA6B,CAAC;AACvD,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,YAAY,wCAAwC,CAAC;AAClE,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAE7C,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEnF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAKrE;AAkGD,oHAAoH;AACpH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAkB5F"}
1
+ {"version":3,"file":"docsMapFile.d.ts","sourceRoot":"","sources":["../../src/docs-map/docsMapFile.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,+BAA+B,CAAC;AAC3D,eAAO,MAAM,YAAY,6BAA6B,CAAC;AACvD,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,YAAY,wCAAwC,CAAC;AAClE,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAE7C,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEnF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAKrE;AAkGD,uEAAuE;AACvE,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEhF,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,2FAA2F;IAC3F,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAgBlG;AAED,2FAA2F;AAC3F,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAM5F"}
@@ -4,7 +4,7 @@ import { mkdir, readFile, writeFile } from 'fs/promises';
4
4
  import { dirname, join } from 'path';
5
5
  import { isEnoent } from '../detection/pathPresent.js';
6
6
  import { formatDateProject } from '../project-defaults.js';
7
- import { DocsMapError, wrapFsError } from './docsMapError.js';
7
+ import { DOCS_MAP_ERROR_KIND, DocsMapError, wrapFsError } from './docsMapError.js';
8
8
  import { discoverMappedDocs } from './discoverDocs.js';
9
9
  import { renderManagedBlock } from './renderDocsMap.js';
10
10
  export const DOCS_MAP_BEGIN = '<!-- BEGIN:cf-docs-map -->';
@@ -21,7 +21,7 @@ export const DOCS_MAP_STATUS = {
21
21
  /** The canonical map path. No pattern search: a renamed project gets a new map (D1). */
22
22
  export function docsMapPath(root, projectName) {
23
23
  if (/[\\/]/.test(projectName)) {
24
- throw new DocsMapError(projectName, 'project name contains a path separator and cannot name the docs map file');
24
+ throw new DocsMapError(projectName, 'project name contains a path separator and cannot name the docs map file', DOCS_MAP_ERROR_KIND.Other);
25
25
  }
26
26
  return join(root, DOCS_MAP_DIR, `${DOCS_MAP_INDEX}-${DOCS_MAP_SEGMENT}.${projectName}.md`);
27
27
  }
@@ -87,9 +87,9 @@ function replaceBlock(existing, block, path) {
87
87
  const lines = existing.split(/(?<=\n)/);
88
88
  const location = locateBlock(lines);
89
89
  if (location.state === 'absent')
90
- throw new DocsMapError(path, `no ${DOCS_MAP_BEGIN} block found`);
90
+ throw new DocsMapError(path, `no ${DOCS_MAP_BEGIN} block found`, DOCS_MAP_ERROR_KIND.Markers);
91
91
  if (location.state === 'broken')
92
- throw new DocsMapError(path, location.problem);
92
+ throw new DocsMapError(path, location.problem, DOCS_MAP_ERROR_KIND.Markers);
93
93
  const eol = lines[location.begin].endsWith('\r\n') ? '\r\n' : '\n';
94
94
  const inserted = Buffer.from(block, 'utf8')
95
95
  .toString('latin1')
@@ -118,8 +118,18 @@ async function writeMap(path, content, encoding) {
118
118
  throw wrapFsError(path, 'write the docs map', error);
119
119
  }
120
120
  }
121
- /** Write or refresh the project's docs map. Discovery runs first, so a discovery error leaves any map untouched. */
122
- export async function writeDocsMap(root, projectName) {
121
+ /** Whether the map file matches what `cf docs map` would write now. */
122
+ export const DOCS_MAP_STATE = {
123
+ Absent: 'absent',
124
+ Current: 'current',
125
+ OutOfDate: 'out-of-date',
126
+ };
127
+ /**
128
+ * Discover, render and compare against the map on disk, without writing (slice 274, D5). Shared
129
+ * by `writeDocsMap` and the build's freshness check. Discovery runs first, so a discovery error
130
+ * surfaces before any map is read; broken or absent markers raise `DocsMapError`.
131
+ */
132
+ export async function compareDocsMap(root, projectName) {
123
133
  const discovery = await discoverMappedDocs(root);
124
134
  const block = renderManagedBlock(discovery.docs, DOCS_MAP_DIR);
125
135
  const path = docsMapPath(root, projectName);
@@ -130,13 +140,19 @@ export async function writeDocsMap(root, projectName) {
130
140
  skippedSymlinks: discovery.skippedSymlinks,
131
141
  };
132
142
  if (existing === undefined) {
133
- await writeMap(path, newMapContent(projectName, block), 'utf8');
134
- return { path, status: DOCS_MAP_STATUS.Created, ...counts };
143
+ return { path, state: DOCS_MAP_STATE.Absent, ...counts, content: newMapContent(projectName, block), encoding: 'utf8' };
135
144
  }
136
145
  const updated = replaceBlock(existing, block, path);
137
- if (updated === existing)
146
+ const state = updated === existing ? DOCS_MAP_STATE.Current : DOCS_MAP_STATE.OutOfDate;
147
+ return { path, state, ...counts, content: updated, encoding: 'latin1' };
148
+ }
149
+ /** Write or refresh the project's docs map. A discovery error leaves any map untouched. */
150
+ export async function writeDocsMap(root, projectName) {
151
+ const { state, content, encoding, path, ...counts } = await compareDocsMap(root, projectName);
152
+ if (state === DOCS_MAP_STATE.Current)
138
153
  return { path, status: DOCS_MAP_STATUS.Unchanged, ...counts };
139
- await writeMap(path, updated, 'latin1');
140
- return { path, status: DOCS_MAP_STATUS.Updated, ...counts };
154
+ await writeMap(path, content, encoding);
155
+ const status = state === DOCS_MAP_STATE.Absent ? DOCS_MAP_STATUS.Created : DOCS_MAP_STATUS.Updated;
156
+ return { path, status, ...counts };
141
157
  }
142
158
  //# sourceMappingURL=docsMapFile.js.map