agents-reverse-engineer 0.2.12 → 0.3.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.
Files changed (49) hide show
  1. package/README.md +4 -2
  2. package/dist/cli/index.js +0 -0
  3. package/dist/cli/update.d.ts.map +1 -1
  4. package/dist/cli/update.js +8 -10
  5. package/dist/cli/update.js.map +1 -1
  6. package/dist/config/defaults.d.ts +4 -4
  7. package/dist/config/defaults.d.ts.map +1 -1
  8. package/dist/config/defaults.js +15 -0
  9. package/dist/config/defaults.js.map +1 -1
  10. package/dist/generation/writers/agents-md.d.ts +7 -1
  11. package/dist/generation/writers/agents-md.d.ts.map +1 -1
  12. package/dist/generation/writers/agents-md.js +59 -4
  13. package/dist/generation/writers/agents-md.js.map +1 -1
  14. package/dist/generation/writers/claude-md.d.ts +6 -2
  15. package/dist/generation/writers/claude-md.d.ts.map +1 -1
  16. package/dist/generation/writers/claude-md.js +74 -11
  17. package/dist/generation/writers/claude-md.js.map +1 -1
  18. package/dist/generation/writers/gemini-md.d.ts +17 -0
  19. package/dist/generation/writers/gemini-md.d.ts.map +1 -0
  20. package/dist/generation/writers/gemini-md.js +96 -0
  21. package/dist/generation/writers/gemini-md.js.map +1 -0
  22. package/dist/generation/writers/index.d.ts +2 -0
  23. package/dist/generation/writers/index.d.ts.map +1 -1
  24. package/dist/generation/writers/index.js +2 -0
  25. package/dist/generation/writers/index.js.map +1 -1
  26. package/dist/generation/writers/opencode-md.d.ts +17 -0
  27. package/dist/generation/writers/opencode-md.d.ts.map +1 -0
  28. package/dist/generation/writers/opencode-md.js +96 -0
  29. package/dist/generation/writers/opencode-md.js.map +1 -0
  30. package/dist/generation/writers/sum.d.ts +3 -1
  31. package/dist/generation/writers/sum.d.ts.map +1 -1
  32. package/dist/generation/writers/sum.js +74 -14
  33. package/dist/generation/writers/sum.js.map +1 -1
  34. package/dist/generation/writers/supplementary.d.ts +8 -2
  35. package/dist/generation/writers/supplementary.d.ts.map +1 -1
  36. package/dist/generation/writers/supplementary.js +80 -7
  37. package/dist/generation/writers/supplementary.js.map +1 -1
  38. package/dist/installer/paths.d.ts +26 -0
  39. package/dist/installer/paths.d.ts.map +1 -1
  40. package/dist/installer/paths.js +55 -0
  41. package/dist/installer/paths.js.map +1 -1
  42. package/dist/integration/templates.d.ts.map +1 -1
  43. package/dist/integration/templates.js +25 -17
  44. package/dist/integration/templates.js.map +1 -1
  45. package/dist/update/orchestrator.d.ts +27 -32
  46. package/dist/update/orchestrator.d.ts.map +1 -1
  47. package/dist/update/orchestrator.js +97 -120
  48. package/dist/update/orchestrator.js.map +1 -1
  49. package/package.json +1 -1
@@ -47,4 +47,30 @@ export declare function resolveInstallPath(runtime: Exclude<Runtime, 'all'>, loc
47
47
  * @returns Absolute path to the settings file
48
48
  */
49
49
  export declare function getSettingsPath(runtime: Exclude<Runtime, 'all'>): string;
50
+ /**
51
+ * Check if a runtime is installed locally in a project.
52
+ *
53
+ * Checks for the presence of the local config directory (e.g., .claude, .opencode, .gemini).
54
+ *
55
+ * @param runtime - Target runtime (claude, opencode, or gemini)
56
+ * @param projectRoot - Project root directory to check
57
+ * @returns True if the runtime's local config directory exists
58
+ */
59
+ export declare function isRuntimeInstalledLocally(runtime: Exclude<Runtime, 'all'>, projectRoot: string): Promise<boolean>;
60
+ /**
61
+ * Check if a runtime is installed globally.
62
+ *
63
+ * Checks for the presence of the global config directory.
64
+ *
65
+ * @param runtime - Target runtime (claude, opencode, or gemini)
66
+ * @returns True if the runtime's global config directory exists
67
+ */
68
+ export declare function isRuntimeInstalledGlobally(runtime: Exclude<Runtime, 'all'>): Promise<boolean>;
69
+ /**
70
+ * Get list of runtimes installed locally in a project.
71
+ *
72
+ * @param projectRoot - Project root directory to check
73
+ * @returns Array of runtime identifiers that are installed locally
74
+ */
75
+ export declare function getInstalledRuntimes(projectRoot: string): Promise<Array<Exclude<Runtime, 'all'>>>;
50
76
  //# sourceMappingURL=paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/installer/paths.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAE/D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,YAAY,CAmC9E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAChC,QAAQ,EAAE,QAAQ,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAUR;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,CAExE"}
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/installer/paths.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAE/D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,YAAY,CAmC9E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAChC,QAAQ,EAAE,QAAQ,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,CAUR;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,CAExE;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,EAChC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,GAC/B,OAAO,CAAC,OAAO,CAAC,CASlB;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAWzC"}
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import * as os from 'node:os';
8
8
  import * as path from 'node:path';
9
+ import { stat } from 'node:fs/promises';
9
10
  /**
10
11
  * Get all supported runtime identifiers (excludes 'all' meta-runtime)
11
12
  *
@@ -92,4 +93,58 @@ export function resolveInstallPath(runtime, location, projectRoot) {
92
93
  export function getSettingsPath(runtime) {
93
94
  return getRuntimePaths(runtime).settingsFile;
94
95
  }
96
+ /**
97
+ * Check if a runtime is installed locally in a project.
98
+ *
99
+ * Checks for the presence of the local config directory (e.g., .claude, .opencode, .gemini).
100
+ *
101
+ * @param runtime - Target runtime (claude, opencode, or gemini)
102
+ * @param projectRoot - Project root directory to check
103
+ * @returns True if the runtime's local config directory exists
104
+ */
105
+ export async function isRuntimeInstalledLocally(runtime, projectRoot) {
106
+ const paths = getRuntimePaths(runtime);
107
+ const localPath = path.join(projectRoot, paths.local);
108
+ try {
109
+ const stats = await stat(localPath);
110
+ return stats.isDirectory();
111
+ }
112
+ catch {
113
+ return false;
114
+ }
115
+ }
116
+ /**
117
+ * Check if a runtime is installed globally.
118
+ *
119
+ * Checks for the presence of the global config directory.
120
+ *
121
+ * @param runtime - Target runtime (claude, opencode, or gemini)
122
+ * @returns True if the runtime's global config directory exists
123
+ */
124
+ export async function isRuntimeInstalledGlobally(runtime) {
125
+ const paths = getRuntimePaths(runtime);
126
+ try {
127
+ const stats = await stat(paths.global);
128
+ return stats.isDirectory();
129
+ }
130
+ catch {
131
+ return false;
132
+ }
133
+ }
134
+ /**
135
+ * Get list of runtimes installed locally in a project.
136
+ *
137
+ * @param projectRoot - Project root directory to check
138
+ * @returns Array of runtime identifiers that are installed locally
139
+ */
140
+ export async function getInstalledRuntimes(projectRoot) {
141
+ const runtimes = getAllRuntimes();
142
+ const installed = [];
143
+ for (const runtime of runtimes) {
144
+ if (await isRuntimeInstalledLocally(runtime, projectRoot)) {
145
+ installed.push(runtime);
146
+ }
147
+ }
148
+ return installed;
149
+ }
95
150
  //# sourceMappingURL=paths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/installer/paths.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAAC,OAAgC;IAC9D,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAE1B,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,gDAAgD;YAChD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAC/E,OAAO;gBACL,MAAM,EAAE,UAAU;gBAClB,KAAK,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BAAmB,EAAE,CAE5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,EAAE,CAE1D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAyCxC"}
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/integration/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAkXtD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,EAAE,CAE1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,mBAAmB,EAAE,CAE5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,mBAAmB,EAAE,CAE1D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAyCxC"}
@@ -46,34 +46,42 @@ Read \`.agents-reverse-engineer/GENERATION-PLAN.md\` and find unchecked tasks (\
46
46
 
47
47
  \`\`\`
48
48
  Analyze and document this file:
49
- 1. Read: <file_path>
50
- 2. Generate .sum content following the format below
51
- 3. Write to: <file_path>.sum
52
- 4. Verify: Read back the .sum file to confirm success
53
- 5. Report: "SUCCESS: <file_path>.sum created" or "FAILED: <reason>"
49
+ 1. Compute content hash: sha256sum <file_path> | cut -d' ' -f1
50
+ 2. Read: <file_path>
51
+ 3. Generate .sum content following the format below (include the content_hash)
52
+ 4. Write to: <file_path>.sum
53
+ 5. Verify: Read back the .sum file to confirm success
54
+ 6. Report: "SUCCESS: <file_path>.sum created" or "FAILED: <reason>"
54
55
  \`\`\`
55
56
 
56
57
  ### .sum File Format
57
58
 
58
- \`\`\`
59
+ \`\`\`yaml
59
60
  ---
60
61
  file_type: <generic|type|config|test|component|service|api|hook|model|schema>
61
62
  generated_at: <ISO timestamp>
63
+ content_hash: <SHA-256 hash - compute with: sha256sum <file> | cut -d' ' -f1>
64
+ purpose: <1-2 sentence description of what this file does>
65
+ public_interface: [func1(), func2(), ClassName]
66
+ dependencies: [express, lodash, ./utils]
67
+ patterns: [singleton, factory, observer]
68
+ related_files: [./types.ts, ./utils.ts]
62
69
  ---
63
70
 
64
- ## Purpose
65
- <1-2 sentence description of what this file does>
66
-
67
- ## Public Interface
68
- <exported functions, classes, types with brief descriptions>
69
-
70
- ## Dependencies
71
- <key imports and what they're used for>
72
-
73
- ## Implementation Notes
74
- <important patterns, algorithms, or gotchas>
71
+ <Detailed 300-500 word summary covering:
72
+ - What the code does and how it works
73
+ - Key implementation details
74
+ - Important usage patterns
75
+ - Notable edge cases or gotchas>
75
76
  \`\`\`
76
77
 
78
+ **Field Guidelines:**
79
+ - \`purpose\`: One-line summary (what + why)
80
+ - \`public_interface\`: Exported functions/classes/types
81
+ - \`dependencies\`: External packages and internal imports
82
+ - \`patterns\`: Design patterns used (singleton, factory, etc.)
83
+ - \`related_files\`: Tightly coupled files (optional)
84
+
77
85
  ### After All Files Complete, Generate AGENTS.md (Post-Order Traversal):
78
86
 
79
87
  Process directories from **deepest to shallowest** so child AGENTS.md files exist before parent directories are documented.
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/integration/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE;QACR,WAAW,EAAE,4DAA4D;QACzE,YAAY,EAAE,0BAA0B;QACxC,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6FA;KACV;IAED,MAAM,EAAE;QACN,WAAW,EAAE,sDAAsD;QACnE,YAAY,EAAE,yCAAyC;QACvD,OAAO,EAAE;;;;;;;;;;;;;;;aAeA;KACV;IAED,IAAI,EAAE;QACJ,WAAW,EAAE,kDAAkD;QAC/D,YAAY,EAAE,EAAE;QAChB,OAAO,EAAE;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GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,uBAAuB,CAAC,UAAU,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCR,CAAC;AACF,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import type { Config } from '../config/schema.js';
2
- import type { StateDatabase, RunRecord } from '../state/index.js';
3
2
  import { type FileChange } from '../change-detection/index.js';
4
3
  import type { UpdateOptions, CleanupResult } from './types.js';
5
4
  /**
@@ -14,31 +13,22 @@ export interface UpdatePlan {
14
13
  cleanup: CleanupResult;
15
14
  /** Directories that need AGENTS.md regeneration */
16
15
  affectedDirs: string[];
17
- /** Base commit (from last run or initial) */
16
+ /** Base commit (not used in frontmatter mode, kept for compatibility) */
18
17
  baseCommit: string;
19
18
  /** Current commit */
20
19
  currentCommit: string;
21
- /** Whether this is first run (no prior state) */
20
+ /** Whether this is first run (no .sum files exist) */
22
21
  isFirstRun: boolean;
23
22
  }
24
23
  /**
25
- * Orchestrates incremental documentation updates.
24
+ * Orchestrates incremental documentation updates using frontmatter-based change detection.
26
25
  */
27
26
  export declare class UpdateOrchestrator {
28
27
  private config;
29
28
  private projectRoot;
30
- private db;
31
29
  constructor(config: Config, projectRoot: string);
32
30
  /**
33
- * Get path to state database.
34
- */
35
- private getDbPath;
36
- /**
37
- * Ensure state directory exists and open database.
38
- */
39
- openState(): Promise<StateDatabase>;
40
- /**
41
- * Close database connection.
31
+ * Close resources (no-op in frontmatter mode, kept for API compatibility).
42
32
  */
43
33
  close(): void;
44
34
  /**
@@ -47,40 +37,45 @@ export declare class UpdateOrchestrator {
47
37
  * @throws Error if not in a git repository
48
38
  */
49
39
  checkPrerequisites(): Promise<void>;
40
+ /**
41
+ * Discover all source files in the project.
42
+ */
43
+ private discoverFiles;
50
44
  /**
51
45
  * Prepare update plan without executing analysis.
52
46
  *
47
+ * Uses frontmatter-based change detection:
48
+ * - Reads content_hash from each .sum file
49
+ * - Compares with current file content hash
50
+ * - Files with mismatched hashes need re-analysis
51
+ *
53
52
  * @param options - Update options
54
53
  * @returns Update plan with files to analyze and cleanup actions
55
54
  */
56
55
  preparePlan(options?: UpdateOptions): Promise<UpdatePlan>;
57
56
  /**
58
- * Update state for a successfully analyzed file.
59
- *
60
- * @param relativePath - Relative path to the file
61
- * @param contentHash - SHA-256 hash of file content
62
- * @param currentCommit - Current git commit hash
57
+ * Record file analyzed (no-op in frontmatter mode - hash is stored in .sum file).
58
+ * Kept for API compatibility.
63
59
  */
64
- recordFileAnalyzed(relativePath: string, contentHash: string, currentCommit: string): Promise<void>;
60
+ recordFileAnalyzed(_relativePath: string, _contentHash: string, _currentCommit: string): Promise<void>;
65
61
  /**
66
- * Remove file from state (for deleted files).
62
+ * Remove file from state (no-op in frontmatter mode).
63
+ * Kept for API compatibility.
67
64
  */
68
- removeFileState(relativePath: string): Promise<void>;
65
+ removeFileState(_relativePath: string): Promise<void>;
69
66
  /**
70
- * Record a completed update run.
71
- *
72
- * @param commitHash - Git commit hash at completion
73
- * @param filesAnalyzed - Number of files analyzed
74
- * @param filesSkipped - Number of files skipped
75
- * @returns Run ID
67
+ * Record a completed update run (no-op in frontmatter mode).
68
+ * Kept for API compatibility.
76
69
  */
77
- recordRun(commitHash: string, filesAnalyzed: number, filesSkipped: number): Promise<number>;
70
+ recordRun(_commitHash: string, _filesAnalyzed: number, _filesSkipped: number): Promise<number>;
78
71
  /**
79
- * Get last run information.
72
+ * Get last run information (not available in frontmatter mode).
73
+ * Kept for API compatibility.
80
74
  */
81
- getLastRun(): Promise<RunRecord | undefined>;
75
+ getLastRun(): Promise<undefined>;
82
76
  /**
83
- * Check if this is the first run (no prior state).
77
+ * Check if this is the first run.
78
+ * In frontmatter mode, checks if any .sum files exist.
84
79
  */
85
80
  isFirstRun(): Promise<boolean>;
86
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/update/orchestrator.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAc,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACd,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,2CAA2C;IAC3C,cAAc,EAAE,UAAU,EAAE,CAAC;IAC7B,sDAAsD;IACtD,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,uCAAuC;IACvC,OAAO,EAAE,aAAa,CAAC;IACvB,mDAAmD;IACnD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,EAAE,CAA8B;gBAE5B,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAK/C;;OAEG;IACH,OAAO,CAAC,SAAS;IAIjB;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC;IAWzC;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUzC;;;;;OAKG;IACG,WAAW,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IAuFnE;;;;;;OA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IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAS;gBAEhB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAK/C;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUzC;;OAEG;YACW,aAAa;IAsB3B;;;;;;;;;;OAUG;IACG,WAAW,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,UAAU,CAAC;IAyEnE;;;OAGG;IACG,kBAAkB,CACtB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC;IAIhB;;;OAGG;IACG,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3D;;;OAGG;IACG,SAAS,CACb,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC;IAKlB;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;IAKtC;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CAIrC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,kBAAkB,CAEpB"}
@@ -1,61 +1,35 @@
1
1
  /**
2
2
  * Update orchestrator
3
3
  *
4
- * Coordinates incremental documentation updates:
4
+ * Coordinates incremental documentation updates using frontmatter-based change detection:
5
5
  * 1. Check git repository status
6
- * 2. Get last run from state database
7
- * 3. Detect changed files since last run
6
+ * 2. Scan for existing .sum files
7
+ * 3. Compare content hashes from frontmatter with current file hashes
8
8
  * 4. Clean up orphaned .sum files
9
9
  * 5. Prepare analysis tasks for changed files
10
10
  * 6. Track affected directories for AGENTS.md regeneration
11
- * 7. Persist new state after successful completion
12
11
  */
13
12
  import * as path from 'node:path';
14
- import { mkdir } from 'node:fs/promises';
15
- import { openDatabase } from '../state/index.js';
16
- import { isGitRepo, getCurrentCommit, getChangedFiles, computeContentHash, } from '../change-detection/index.js';
13
+ import { isGitRepo, getCurrentCommit, computeContentHash, } from '../change-detection/index.js';
17
14
  import { cleanupOrphans, getAffectedDirectories } from './orphan-cleaner.js';
18
- /** State directory name (relative to project root) */
19
- const STATE_DIR = '.agents-reverse-engineer';
20
- /** State database filename */
21
- const STATE_DB = 'state.db';
15
+ import { readSumFile, getSumPath } from '../generation/writers/sum.js';
16
+ import { walkDirectory } from '../discovery/walker.js';
17
+ import { applyFilters, createGitignoreFilter, createVendorFilter, createBinaryFilter, createCustomFilter, } from '../discovery/filters/index.js';
22
18
  /**
23
- * Orchestrates incremental documentation updates.
19
+ * Orchestrates incremental documentation updates using frontmatter-based change detection.
24
20
  */
25
21
  export class UpdateOrchestrator {
26
22
  config;
27
23
  projectRoot;
28
- db = null;
29
24
  constructor(config, projectRoot) {
30
25
  this.config = config;
31
26
  this.projectRoot = projectRoot;
32
27
  }
33
28
  /**
34
- * Get path to state database.
35
- */
36
- getDbPath() {
37
- return path.join(this.projectRoot, STATE_DIR, STATE_DB);
38
- }
39
- /**
40
- * Ensure state directory exists and open database.
41
- */
42
- async openState() {
43
- if (this.db)
44
- return this.db;
45
- // Ensure state directory exists
46
- const stateDir = path.join(this.projectRoot, STATE_DIR);
47
- await mkdir(stateDir, { recursive: true });
48
- this.db = openDatabase(this.getDbPath());
49
- return this.db;
50
- }
51
- /**
52
- * Close database connection.
29
+ * Close resources (no-op in frontmatter mode, kept for API compatibility).
53
30
  */
54
31
  close() {
55
- if (this.db) {
56
- this.db.close();
57
- this.db = null;
58
- }
32
+ // No database to close in frontmatter mode
59
33
  }
60
34
  /**
61
35
  * Check prerequisites for update.
@@ -69,130 +43,133 @@ export class UpdateOrchestrator {
69
43
  'The update command requires a git repository for change detection.');
70
44
  }
71
45
  }
46
+ /**
47
+ * Discover all source files in the project.
48
+ */
49
+ async discoverFiles() {
50
+ // Create filters
51
+ const gitignoreFilter = await createGitignoreFilter(this.projectRoot);
52
+ const vendorFilter = createVendorFilter(this.config.exclude.vendorDirs);
53
+ const binaryFilter = createBinaryFilter({
54
+ maxFileSize: this.config.options.maxFileSize,
55
+ additionalExtensions: this.config.exclude.binaryExtensions,
56
+ });
57
+ const customFilter = createCustomFilter(this.config.exclude.patterns, this.projectRoot);
58
+ const filters = [gitignoreFilter, vendorFilter, binaryFilter, customFilter];
59
+ // Walk directory
60
+ const files = await walkDirectory({
61
+ cwd: this.projectRoot,
62
+ followSymlinks: this.config.options.followSymlinks,
63
+ });
64
+ // Apply filters
65
+ const filterResult = await applyFilters(files, filters);
66
+ return filterResult.included;
67
+ }
72
68
  /**
73
69
  * Prepare update plan without executing analysis.
74
70
  *
71
+ * Uses frontmatter-based change detection:
72
+ * - Reads content_hash from each .sum file
73
+ * - Compares with current file content hash
74
+ * - Files with mismatched hashes need re-analysis
75
+ *
75
76
  * @param options - Update options
76
77
  * @returns Update plan with files to analyze and cleanup actions
77
78
  */
78
79
  async preparePlan(options = {}) {
79
80
  await this.checkPrerequisites();
80
- const db = await this.openState();
81
- // Get current commit
81
+ // Get current commit for reference
82
82
  const currentCommit = await getCurrentCommit(this.projectRoot);
83
- // Get last run to determine base commit
84
- const lastRun = db.getLastRun();
85
- const isFirstRun = !lastRun;
86
- const baseCommit = lastRun?.commit_hash ?? currentCommit;
87
- // If first run or same commit, no committed changes
88
- let changes = [];
89
- if (!isFirstRun && baseCommit !== currentCommit) {
90
- const result = await getChangedFiles(this.projectRoot, baseCommit, { includeUncommitted: options.includeUncommitted });
91
- changes = result.changes;
92
- }
93
- else if (options.includeUncommitted) {
94
- // Even if no committed changes, check uncommitted
95
- const result = await getChangedFiles(this.projectRoot, currentCommit, // Use current as base (no committed diff)
96
- { includeUncommitted: true });
97
- changes = result.changes;
98
- }
99
- // Separate files by status for different handling
100
- const filesToAnalyze = changes.filter(c => c.status === 'added' || c.status === 'modified' || c.status === 'renamed');
101
- const deletedOrRenamed = changes.filter(c => c.status === 'deleted' || c.status === 'renamed');
102
- // Filter out files that haven't actually changed (content hash match)
103
- const actuallyChanged = [];
83
+ // Discover all source files
84
+ const allFiles = await this.discoverFiles();
85
+ const filesToAnalyze = [];
104
86
  const filesToSkip = [];
105
- for (const change of filesToAnalyze) {
106
- if (change.status === 'added') {
107
- // New files are always analyzed
108
- actuallyChanged.push(change);
109
- }
110
- else {
111
- // For modified/renamed, check content hash
112
- const filePath = path.join(this.projectRoot, change.path);
113
- try {
114
- const currentHash = await computeContentHash(filePath);
115
- const stored = db.getFile(change.path);
116
- if (!stored || stored.content_hash !== currentHash) {
117
- actuallyChanged.push(change);
118
- }
119
- else {
120
- filesToSkip.push(change.path);
121
- }
87
+ const deletedOrRenamed = [];
88
+ // Track which .sum files we've seen (to detect orphans)
89
+ const seenSumFiles = new Set();
90
+ // Check each file against its .sum file
91
+ for (const relativePath of allFiles) {
92
+ const filePath = path.join(this.projectRoot, relativePath);
93
+ const sumPath = getSumPath(filePath);
94
+ seenSumFiles.add(sumPath);
95
+ try {
96
+ // Read existing .sum file
97
+ const sumContent = await readSumFile(sumPath);
98
+ if (!sumContent) {
99
+ // No .sum file exists - file needs analysis
100
+ filesToAnalyze.push({ path: relativePath, status: 'added' });
101
+ continue;
102
+ }
103
+ // Compare content hashes
104
+ const currentHash = await computeContentHash(filePath);
105
+ const storedHash = sumContent.contentHash;
106
+ if (!storedHash || storedHash !== currentHash) {
107
+ // Hash mismatch or no hash stored - file needs re-analysis
108
+ filesToAnalyze.push({ path: relativePath, status: 'modified' });
122
109
  }
123
- catch {
124
- // File can't be read - skip it
125
- filesToSkip.push(change.path);
110
+ else {
111
+ // Hash matches - skip this file
112
+ filesToSkip.push(relativePath);
126
113
  }
127
114
  }
115
+ catch {
116
+ // Error reading file - skip it
117
+ filesToSkip.push(relativePath);
118
+ }
128
119
  }
129
- // Cleanup orphans (deleted and renamed old paths)
120
+ // Cleanup orphans (deleted files whose .sum files still exist)
130
121
  const cleanup = await cleanupOrphans(this.projectRoot, deletedOrRenamed, options.dryRun ?? false);
131
122
  // Get directories affected by changes (for AGENTS.md regeneration)
132
- const affectedDirs = Array.from(getAffectedDirectories(actuallyChanged));
123
+ const affectedDirs = Array.from(getAffectedDirectories(filesToAnalyze));
124
+ // Determine if this is first run (no files to skip means no existing .sum files)
125
+ const isFirstRun = filesToSkip.length === 0 && filesToAnalyze.length > 0;
133
126
  return {
134
- filesToAnalyze: actuallyChanged,
127
+ filesToAnalyze,
135
128
  filesToSkip,
136
129
  cleanup,
137
130
  affectedDirs,
138
- baseCommit,
131
+ baseCommit: currentCommit, // Not used in frontmatter mode
139
132
  currentCommit,
140
133
  isFirstRun,
141
134
  };
142
135
  }
143
136
  /**
144
- * Update state for a successfully analyzed file.
145
- *
146
- * @param relativePath - Relative path to the file
147
- * @param contentHash - SHA-256 hash of file content
148
- * @param currentCommit - Current git commit hash
137
+ * Record file analyzed (no-op in frontmatter mode - hash is stored in .sum file).
138
+ * Kept for API compatibility.
149
139
  */
150
- async recordFileAnalyzed(relativePath, contentHash, currentCommit) {
151
- const db = await this.openState();
152
- db.upsertFile({
153
- path: relativePath,
154
- content_hash: contentHash,
155
- sum_generated_at: new Date().toISOString(),
156
- last_analyzed_commit: currentCommit,
157
- });
140
+ async recordFileAnalyzed(_relativePath, _contentHash, _currentCommit) {
141
+ // No-op: content hash is stored in .sum file frontmatter
158
142
  }
159
143
  /**
160
- * Remove file from state (for deleted files).
144
+ * Remove file from state (no-op in frontmatter mode).
145
+ * Kept for API compatibility.
161
146
  */
162
- async removeFileState(relativePath) {
163
- const db = await this.openState();
164
- db.deleteFile(relativePath);
147
+ async removeFileState(_relativePath) {
148
+ // No-op: .sum file cleanup is handled separately
165
149
  }
166
150
  /**
167
- * Record a completed update run.
168
- *
169
- * @param commitHash - Git commit hash at completion
170
- * @param filesAnalyzed - Number of files analyzed
171
- * @param filesSkipped - Number of files skipped
172
- * @returns Run ID
151
+ * Record a completed update run (no-op in frontmatter mode).
152
+ * Kept for API compatibility.
173
153
  */
174
- async recordRun(commitHash, filesAnalyzed, filesSkipped) {
175
- const db = await this.openState();
176
- return db.insertRun({
177
- commit_hash: commitHash,
178
- completed_at: new Date().toISOString(),
179
- files_analyzed: filesAnalyzed,
180
- files_skipped: filesSkipped,
181
- });
154
+ async recordRun(_commitHash, _filesAnalyzed, _filesSkipped) {
155
+ // No-op: no run history in frontmatter mode
156
+ return 0;
182
157
  }
183
158
  /**
184
- * Get last run information.
159
+ * Get last run information (not available in frontmatter mode).
160
+ * Kept for API compatibility.
185
161
  */
186
162
  async getLastRun() {
187
- const db = await this.openState();
188
- return db.getLastRun();
163
+ // No run history in frontmatter mode
164
+ return undefined;
189
165
  }
190
166
  /**
191
- * Check if this is the first run (no prior state).
167
+ * Check if this is the first run.
168
+ * In frontmatter mode, checks if any .sum files exist.
192
169
  */
193
170
  async isFirstRun() {
194
- const db = await this.openState();
195
- return !db.getLastRun();
171
+ const plan = await this.preparePlan({ dryRun: true });
172
+ return plan.isFirstRun;
196
173
  }
197
174
  }
198
175
  /**