@codeledger/cowork 0.2.1
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/LICENSE +27 -0
- package/dist/artifact-writer.d.ts +24 -0
- package/dist/artifact-writer.d.ts.map +1 -0
- package/dist/artifact-writer.js +107 -0
- package/dist/artifact-writer.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/workspace-scanner.d.ts +22 -0
- package/dist/workspace-scanner.d.ts.map +1 -0
- package/dist/workspace-scanner.js +233 -0
- package/dist/workspace-scanner.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Intelligent Context AI, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Note: This license applies to the CLI wrapper, types, repository scanning,
|
|
26
|
+
instrumentation, harness, and report packages (the "Plugin"). The scoring
|
|
27
|
+
engine (packages/core-engine/bin/) is licensed separately under LICENSE-CORE.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact writer — generates Cowork output files.
|
|
3
|
+
*
|
|
4
|
+
* Writes:
|
|
5
|
+
* .codeledger/context-bundle.json
|
|
6
|
+
* .codeledger/trace.json
|
|
7
|
+
* .codeledger/excerpts/{path}.txt
|
|
8
|
+
* .codeledger/progress-snapshot.json
|
|
9
|
+
* .codeledger/compact-summary.md
|
|
10
|
+
*/
|
|
11
|
+
import type { CoworkBundle, KnowledgeWeights, KnowledgeScoredFile } from '@codeledger/types';
|
|
12
|
+
/**
|
|
13
|
+
* Write all Cowork artifacts to the .codeledger/ directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare function writeCoworkArtifacts(workspaceRoot: string, bundle: CoworkBundle, scored: KnowledgeScoredFile[], weights: KnowledgeWeights): void;
|
|
16
|
+
/**
|
|
17
|
+
* Write progress snapshot artifact.
|
|
18
|
+
*/
|
|
19
|
+
export declare function writeProgressSnapshot(workspaceRoot: string, bundle: CoworkBundle, filesRead?: string[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Write compact summary (markdown).
|
|
22
|
+
*/
|
|
23
|
+
export declare function writeCompactSummary(workspaceRoot: string, bundle: CoworkBundle): void;
|
|
24
|
+
//# sourceMappingURL=artifact-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-writer.d.ts","sourceRoot":"","sources":["../src/artifact-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,YAAY,EAGZ,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,mBAAmB,EAAE,EAC7B,OAAO,EAAE,gBAAgB,GACxB,IAAI,CAuCN;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,YAAY,EACpB,SAAS,GAAE,MAAM,EAAO,GACvB,IAAI,CAqBN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,YAAY,GACnB,IAAI,CAgCN"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact writer — generates Cowork output files.
|
|
3
|
+
*
|
|
4
|
+
* Writes:
|
|
5
|
+
* .codeledger/context-bundle.json
|
|
6
|
+
* .codeledger/trace.json
|
|
7
|
+
* .codeledger/excerpts/{path}.txt
|
|
8
|
+
* .codeledger/progress-snapshot.json
|
|
9
|
+
* .codeledger/compact-summary.md
|
|
10
|
+
*/
|
|
11
|
+
import { writeFileSync, mkdirSync, existsSync } from 'node:fs';
|
|
12
|
+
import { join, dirname } from 'node:path';
|
|
13
|
+
import { extractKnowledgeExcerpt } from '@codeledger/selector';
|
|
14
|
+
/**
|
|
15
|
+
* Write all Cowork artifacts to the .codeledger/ directory.
|
|
16
|
+
*/
|
|
17
|
+
export function writeCoworkArtifacts(workspaceRoot, bundle, scored, weights) {
|
|
18
|
+
const baseDir = join(workspaceRoot, '.codeledger');
|
|
19
|
+
ensureDir(baseDir);
|
|
20
|
+
// Write context-bundle.json
|
|
21
|
+
const bundlePath = join(baseDir, 'context-bundle.json');
|
|
22
|
+
writeFileSync(bundlePath, JSON.stringify(bundle, null, 2) + '\n');
|
|
23
|
+
// Write trace.json
|
|
24
|
+
const trace = {
|
|
25
|
+
run_id: bundle.run_id,
|
|
26
|
+
timestamp: bundle.created_at,
|
|
27
|
+
scoring_profile: 'knowledge',
|
|
28
|
+
signals: weights,
|
|
29
|
+
stop_rule: {
|
|
30
|
+
sufficiency_threshold: bundle.stop_rule.sufficiency_threshold,
|
|
31
|
+
reached_at_rank: bundle.stop_rule.terminated_at_rank,
|
|
32
|
+
},
|
|
33
|
+
ranked_top: scored.slice(0, 30).map((f) => ({
|
|
34
|
+
path: f.path,
|
|
35
|
+
score: Math.round(f.score * 1000) / 1000,
|
|
36
|
+
evidence: f.reasons,
|
|
37
|
+
})),
|
|
38
|
+
};
|
|
39
|
+
writeFileSync(join(baseDir, 'trace.json'), JSON.stringify(trace, null, 2) + '\n');
|
|
40
|
+
// Write excerpts
|
|
41
|
+
const excerptsDir = join(baseDir, 'excerpts');
|
|
42
|
+
ensureDir(excerptsDir);
|
|
43
|
+
for (const file of bundle.selected) {
|
|
44
|
+
const excerpt = extractKnowledgeExcerpt(workspaceRoot, file.path, bundle.intent.tokens);
|
|
45
|
+
const excerptPath = join(workspaceRoot, file.excerpt.ref);
|
|
46
|
+
ensureDir(dirname(excerptPath));
|
|
47
|
+
writeFileSync(excerptPath, excerpt.content);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Write progress snapshot artifact.
|
|
52
|
+
*/
|
|
53
|
+
export function writeProgressSnapshot(workspaceRoot, bundle, filesRead = []) {
|
|
54
|
+
const baseDir = join(workspaceRoot, '.codeledger');
|
|
55
|
+
ensureDir(baseDir);
|
|
56
|
+
const snapshot = {
|
|
57
|
+
run_id: bundle.run_id,
|
|
58
|
+
timestamp: new Date().toISOString(),
|
|
59
|
+
last_intent: bundle.intent.text,
|
|
60
|
+
bundle_hash: bundle.workspace.fingerprint,
|
|
61
|
+
files_read: filesRead,
|
|
62
|
+
open_threads: [],
|
|
63
|
+
next_suggested_files: bundle.selected
|
|
64
|
+
.filter((f) => !filesRead.includes(f.path))
|
|
65
|
+
.slice(0, 5)
|
|
66
|
+
.map((f) => f.path),
|
|
67
|
+
};
|
|
68
|
+
writeFileSync(join(baseDir, 'progress-snapshot.json'), JSON.stringify(snapshot, null, 2) + '\n');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Write compact summary (markdown).
|
|
72
|
+
*/
|
|
73
|
+
export function writeCompactSummary(workspaceRoot, bundle) {
|
|
74
|
+
const baseDir = join(workspaceRoot, '.codeledger');
|
|
75
|
+
ensureDir(baseDir);
|
|
76
|
+
const lines = [
|
|
77
|
+
'# Cowork Session Summary',
|
|
78
|
+
'',
|
|
79
|
+
`**Intent:** ${bundle.intent.text}`,
|
|
80
|
+
`**Mode:** ${bundle.mode}`,
|
|
81
|
+
`**Bundle:** ${bundle.selected.length} files selected from ${bundle.excluded_summary.total_seen} total`,
|
|
82
|
+
`**Stop rule:** ${bundle.stop_rule.termination_reason} at rank ${bundle.stop_rule.terminated_at_rank}`,
|
|
83
|
+
'',
|
|
84
|
+
'## Selected Files',
|
|
85
|
+
'',
|
|
86
|
+
];
|
|
87
|
+
for (const file of bundle.selected) {
|
|
88
|
+
const reasons = file.reasons.join(', ');
|
|
89
|
+
lines.push(`- **${file.path}** (score: ${file.score}) — ${reasons}`);
|
|
90
|
+
}
|
|
91
|
+
lines.push('');
|
|
92
|
+
lines.push('## Budget Usage');
|
|
93
|
+
lines.push('');
|
|
94
|
+
lines.push(`- Files: ${bundle.selected.length} / ${bundle.budgets.max_files}`);
|
|
95
|
+
lines.push(`- Estimated tokens: ~${bundle.selected.reduce((s, f) => s + Math.ceil(f.excerpt.lines_est * 5), 0)} / ${bundle.budgets.max_tokens_est}`);
|
|
96
|
+
lines.push('');
|
|
97
|
+
lines.push('---');
|
|
98
|
+
lines.push('*Generated by CodeLedger Context Governor*');
|
|
99
|
+
lines.push('');
|
|
100
|
+
writeFileSync(join(baseDir, 'compact-summary.md'), lines.join('\n'));
|
|
101
|
+
}
|
|
102
|
+
function ensureDir(dirPath) {
|
|
103
|
+
if (!existsSync(dirPath)) {
|
|
104
|
+
mkdirSync(dirPath, { recursive: true });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=artifact-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-writer.js","sourceRoot":"","sources":["../src/artifact-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQ1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,aAAqB,EACrB,MAAoB,EACpB,MAA6B,EAC7B,OAAyB;IAEzB,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACnD,SAAS,CAAC,OAAO,CAAC,CAAC;IAEnB,4BAA4B;IAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;IACxD,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAElE,mBAAmB;IACnB,MAAM,KAAK,GAAgB;QACzB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,EAAE,MAAM,CAAC,UAAU;QAC5B,eAAe,EAAE,WAAW;QAC5B,OAAO,EAAE,OAAO;QAChB,SAAS,EAAE;YACT,qBAAqB,EAAE,MAAM,CAAC,SAAS,CAAC,qBAAqB;YAC7D,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,kBAAkB;SACrD;QACD,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAA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ourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace scanner for knowledge mode.
|
|
3
|
+
*
|
|
4
|
+
* Lightweight alternative to the repo scanner: no dependency graph,
|
|
5
|
+
* no git churn, no test mapping. Extracts metadata from files using
|
|
6
|
+
* only filesystem information and basic content analysis.
|
|
7
|
+
*
|
|
8
|
+
* Supported file types for content extraction: .md, .txt, .json, .yaml, .yml
|
|
9
|
+
* Unsupported types: metadata only (path, mtime, size)
|
|
10
|
+
*/
|
|
11
|
+
import type { WorkspaceIndex } from '@codeledger/types';
|
|
12
|
+
export interface ScanWorkspaceOptions {
|
|
13
|
+
root: string;
|
|
14
|
+
excludes?: string[];
|
|
15
|
+
maxFiles?: number;
|
|
16
|
+
log?: (...args: unknown[]) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Scan a workspace directory and build a WorkspaceIndex.
|
|
20
|
+
*/
|
|
21
|
+
export declare function scanWorkspace(opts: ScanWorkspaceOptions): WorkspaceIndex;
|
|
22
|
+
//# sourceMappingURL=workspace-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-scanner.d.ts","sourceRoot":"","sources":["../src/workspace-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,mBAAmB,CAAC;AAmC3B,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CA2CxE"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace scanner for knowledge mode.
|
|
3
|
+
*
|
|
4
|
+
* Lightweight alternative to the repo scanner: no dependency graph,
|
|
5
|
+
* no git churn, no test mapping. Extracts metadata from files using
|
|
6
|
+
* only filesystem information and basic content analysis.
|
|
7
|
+
*
|
|
8
|
+
* Supported file types for content extraction: .md, .txt, .json, .yaml, .yml
|
|
9
|
+
* Unsupported types: metadata only (path, mtime, size)
|
|
10
|
+
*/
|
|
11
|
+
import { readFileSync, readdirSync, statSync } from 'node:fs';
|
|
12
|
+
import { join, relative, extname } from 'node:path';
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
|
+
import { detectSelectionMode } from '@codeledger/selector';
|
|
15
|
+
/** Max file size to read (10 MB) */
|
|
16
|
+
const MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
17
|
+
/** Max files to scan (hard cap for performance) */
|
|
18
|
+
const MAX_FILES = 5000;
|
|
19
|
+
/** Supported extensions for full content analysis */
|
|
20
|
+
const SUPPORTED_CONTENT_EXTENSIONS = new Set(['.md', '.txt', '.json', '.yaml', '.yml']);
|
|
21
|
+
/** Default exclude patterns */
|
|
22
|
+
const DEFAULT_EXCLUDES = new Set([
|
|
23
|
+
'node_modules', '.git', '.svn', '.hg', 'dist', 'build', 'out',
|
|
24
|
+
'__pycache__', '.cache', '.codeledger', '.cowork', '.vscode',
|
|
25
|
+
'.idea', 'vendor', 'target', '.next', '.nuxt',
|
|
26
|
+
]);
|
|
27
|
+
/** Map extension to CoworkFileType */
|
|
28
|
+
function classifyFileType(ext) {
|
|
29
|
+
const lower = ext.toLowerCase();
|
|
30
|
+
if (lower === '.md' || lower === '.mdx')
|
|
31
|
+
return 'markdown';
|
|
32
|
+
if (lower === '.txt' || lower === '.rst' || lower === '.adoc')
|
|
33
|
+
return 'text';
|
|
34
|
+
if (lower === '.json')
|
|
35
|
+
return 'json';
|
|
36
|
+
if (lower === '.yaml' || lower === '.yml')
|
|
37
|
+
return 'yaml';
|
|
38
|
+
// Code extensions
|
|
39
|
+
const codeExts = new Set([
|
|
40
|
+
'.ts', '.tsx', '.js', '.jsx', '.py', '.go', '.rs', '.java',
|
|
41
|
+
'.kt', '.cs', '.c', '.cpp', '.h', '.rb', '.php', '.swift',
|
|
42
|
+
]);
|
|
43
|
+
if (codeExts.has(lower))
|
|
44
|
+
return 'code';
|
|
45
|
+
return 'unknown';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Scan a workspace directory and build a WorkspaceIndex.
|
|
49
|
+
*/
|
|
50
|
+
export function scanWorkspace(opts) {
|
|
51
|
+
const { root, excludes = [], maxFiles = MAX_FILES, log = () => { }, } = opts;
|
|
52
|
+
const excludeSet = new Set([...DEFAULT_EXCLUDES, ...excludes]);
|
|
53
|
+
const files = [];
|
|
54
|
+
const rootFiles = [];
|
|
55
|
+
const allPaths = [];
|
|
56
|
+
log(' Scanning workspace...');
|
|
57
|
+
walkDir(root, root, excludeSet, files, rootFiles, maxFiles);
|
|
58
|
+
log(` Found ${files.length} files`);
|
|
59
|
+
for (const f of files) {
|
|
60
|
+
allPaths.push(f.path);
|
|
61
|
+
}
|
|
62
|
+
// Detect mode
|
|
63
|
+
const mode = detectSelectionMode({
|
|
64
|
+
filePaths: allPaths,
|
|
65
|
+
rootFiles,
|
|
66
|
+
});
|
|
67
|
+
log(` Detected mode: ${mode}`);
|
|
68
|
+
// Compute workspace fingerprint (hash of paths + mtimes + sizes)
|
|
69
|
+
const fingerprintData = files
|
|
70
|
+
.map((f) => `${f.path}:${f.mtime}:${f.size_bytes}`)
|
|
71
|
+
.sort()
|
|
72
|
+
.join('\n');
|
|
73
|
+
const fingerprint = `ws_${createHash('md5').update(fingerprintData).digest('hex').slice(0, 12)}`;
|
|
74
|
+
return {
|
|
75
|
+
generated_at: new Date().toISOString(),
|
|
76
|
+
root,
|
|
77
|
+
fingerprint,
|
|
78
|
+
file_count: files.length,
|
|
79
|
+
files,
|
|
80
|
+
mode,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function walkDir(root, currentDir, excludes, results, rootFiles, maxFiles) {
|
|
84
|
+
if (results.length >= maxFiles)
|
|
85
|
+
return;
|
|
86
|
+
let entries;
|
|
87
|
+
try {
|
|
88
|
+
entries = readdirSync(currentDir);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
for (const entry of entries) {
|
|
94
|
+
if (results.length >= maxFiles)
|
|
95
|
+
return;
|
|
96
|
+
if (entry.startsWith('.') && excludes.has(entry.slice(1)))
|
|
97
|
+
continue;
|
|
98
|
+
if (excludes.has(entry))
|
|
99
|
+
continue;
|
|
100
|
+
const absPath = join(currentDir, entry);
|
|
101
|
+
let stat;
|
|
102
|
+
try {
|
|
103
|
+
stat = statSync(absPath);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (stat.isDirectory()) {
|
|
109
|
+
walkDir(root, absPath, excludes, results, rootFiles, maxFiles);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (!stat.isFile())
|
|
113
|
+
continue;
|
|
114
|
+
const relPath = relative(root, absPath);
|
|
115
|
+
const ext = extname(relPath);
|
|
116
|
+
const fileType = classifyFileType(ext);
|
|
117
|
+
// Track root-level files for mode detection
|
|
118
|
+
if (currentDir === root) {
|
|
119
|
+
rootFiles.push(entry);
|
|
120
|
+
}
|
|
121
|
+
// Skip very large files
|
|
122
|
+
if (stat.size > MAX_FILE_SIZE)
|
|
123
|
+
continue;
|
|
124
|
+
const fileInfo = {
|
|
125
|
+
path: relPath,
|
|
126
|
+
extension: ext,
|
|
127
|
+
size_bytes: stat.size,
|
|
128
|
+
mtime: stat.mtime.toISOString(),
|
|
129
|
+
lines: 0,
|
|
130
|
+
type: fileType,
|
|
131
|
+
};
|
|
132
|
+
// Extract content for supported types
|
|
133
|
+
if (SUPPORTED_CONTENT_EXTENSIONS.has(ext.toLowerCase()) && stat.size <= MAX_FILE_SIZE) {
|
|
134
|
+
try {
|
|
135
|
+
const content = readFileSync(absPath, 'utf-8');
|
|
136
|
+
// Skip binary
|
|
137
|
+
if (content.length > 0 && content.slice(0, 8192).includes('\0'))
|
|
138
|
+
continue;
|
|
139
|
+
const lines = content.split('\n');
|
|
140
|
+
fileInfo.lines = lines.length;
|
|
141
|
+
fileInfo.content_keywords = extractKnowledgeKeywords(content, ext);
|
|
142
|
+
// Extract markdown headers
|
|
143
|
+
if (ext.toLowerCase() === '.md' || ext.toLowerCase() === '.mdx') {
|
|
144
|
+
fileInfo.markdown_headers = extractMarkdownHeaders(lines);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Unreadable — keep metadata only
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
results.push(fileInfo);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Extract keywords from knowledge file content.
|
|
156
|
+
* Simpler than code keyword extraction: focuses on meaningful words
|
|
157
|
+
* from headers, titles, and first N lines.
|
|
158
|
+
*/
|
|
159
|
+
function extractKnowledgeKeywords(content, ext) {
|
|
160
|
+
const tokens = new Set();
|
|
161
|
+
const lines = content.split('\n');
|
|
162
|
+
const lower = ext.toLowerCase();
|
|
163
|
+
if (lower === '.md' || lower === '.mdx') {
|
|
164
|
+
// Extract from markdown headers and first 50 lines
|
|
165
|
+
for (let i = 0; i < Math.min(lines.length, 200); i++) {
|
|
166
|
+
const line = lines[i];
|
|
167
|
+
// Headers are high-value
|
|
168
|
+
if (line.match(/^#{1,6}\s/)) {
|
|
169
|
+
extractWords(line.replace(/^#{1,6}\s*/, ''), tokens);
|
|
170
|
+
}
|
|
171
|
+
else if (i < 50) {
|
|
172
|
+
extractWords(line, tokens);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else if (lower === '.json') {
|
|
177
|
+
// Extract JSON keys from first 50 lines
|
|
178
|
+
const keyRe = /["']([a-zA-Z_][a-zA-Z0-9_]*)["']\s*:/g;
|
|
179
|
+
for (let i = 0; i < Math.min(lines.length, 50); i++) {
|
|
180
|
+
let m;
|
|
181
|
+
keyRe.lastIndex = 0;
|
|
182
|
+
while ((m = keyRe.exec(lines[i])) !== null) {
|
|
183
|
+
addToken(m[1], tokens);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else if (lower === '.yaml' || lower === '.yml') {
|
|
188
|
+
// Extract YAML keys from first 50 lines
|
|
189
|
+
const yamlKeyRe = /^(\s*)([a-zA-Z_][a-zA-Z0-9_]*)\s*:/;
|
|
190
|
+
for (let i = 0; i < Math.min(lines.length, 50); i++) {
|
|
191
|
+
const m = yamlKeyRe.exec(lines[i]);
|
|
192
|
+
if (m) {
|
|
193
|
+
addToken(m[2], tokens);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
// Plain text: first 50 lines
|
|
199
|
+
for (let i = 0; i < Math.min(lines.length, 50); i++) {
|
|
200
|
+
extractWords(lines[i], tokens);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return [...tokens].slice(0, 50);
|
|
204
|
+
}
|
|
205
|
+
function extractWords(text, tokens) {
|
|
206
|
+
const words = text.toLowerCase().split(/[^\p{L}\p{N}]+/u);
|
|
207
|
+
for (const w of words) {
|
|
208
|
+
if (w.length > 2) {
|
|
209
|
+
tokens.add(w);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function addToken(name, tokens) {
|
|
214
|
+
const parts = name
|
|
215
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
216
|
+
.toLowerCase()
|
|
217
|
+
.split(/[_\-]+/)
|
|
218
|
+
.filter((p) => p.length > 2);
|
|
219
|
+
for (const p of parts) {
|
|
220
|
+
tokens.add(p);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function extractMarkdownHeaders(lines) {
|
|
224
|
+
const headers = [];
|
|
225
|
+
for (const line of lines) {
|
|
226
|
+
const m = line.match(/^(#{1,6})\s+(.+)/);
|
|
227
|
+
if (m) {
|
|
228
|
+
headers.push(m[2].trim());
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return headers;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=workspace-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-scanner.js","sourceRoot":"","sources":["../src/workspace-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,oCAAoC;AACpC,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEvC,mDAAmD;AACnD,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,qDAAqD;AACrD,MAAM,4BA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ACrD,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1D,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,MAAmB;IACjD,MAAM,KAAK,GAAG,IAAI;SACf,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,WAAW,EAAE;SACb,KAAK,CAAC,QAAQ,CAAC;SACf,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAe;IAC7C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACzC,IAAI,CAAC,EAAE,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codeledger/cowork",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Cowork Context Governor — deterministic context selection for Claude Cowork",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/codeledgerECF/codeledger-blackbox.git",
|
|
10
|
+
"directory": "packages/cowork"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@codeledger/types": "0.2.1",
|
|
28
|
+
"@codeledger/selector": "0.2.1"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.4.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"clean": "rm -rf dist"
|
|
37
|
+
}
|
|
38
|
+
}
|