spec-agent 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +256 -0
- package/bin/spec-agent.js +14 -0
- package/dist/commands/analyze.d.ts +16 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +283 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/clean.d.ts +9 -0
- package/dist/commands/clean.d.ts.map +1 -0
- package/dist/commands/clean.js +109 -0
- package/dist/commands/clean.js.map +1 -0
- package/dist/commands/dispatch.d.ts +12 -0
- package/dist/commands/dispatch.d.ts.map +1 -0
- package/dist/commands/dispatch.js +232 -0
- package/dist/commands/dispatch.js.map +1 -0
- package/dist/commands/doctor.d.ts +9 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +153 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/learn.d.ts +13 -0
- package/dist/commands/learn.d.ts.map +1 -0
- package/dist/commands/learn.js +234 -0
- package/dist/commands/learn.js.map +1 -0
- package/dist/commands/merge.d.ts +11 -0
- package/dist/commands/merge.d.ts.map +1 -0
- package/dist/commands/merge.js +335 -0
- package/dist/commands/merge.js.map +1 -0
- package/dist/commands/pipeline.d.ts +19 -0
- package/dist/commands/pipeline.d.ts.map +1 -0
- package/dist/commands/pipeline.js +266 -0
- package/dist/commands/pipeline.js.map +1 -0
- package/dist/commands/plan.d.ts +13 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +314 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/scan.d.ts +28 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +488 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/commands/status.d.ts +8 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +146 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -0
- package/dist/index.js.map +1 -0
- package/dist/services/document-parser.d.ts +49 -0
- package/dist/services/document-parser.d.ts.map +1 -0
- package/dist/services/document-parser.js +499 -0
- package/dist/services/document-parser.js.map +1 -0
- package/dist/services/llm.d.ts +61 -0
- package/dist/services/llm.d.ts.map +1 -0
- package/dist/services/llm.js +716 -0
- package/dist/services/llm.js.map +1 -0
- package/dist/types.d.ts +159 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/file.d.ts +10 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +96 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +55 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +48 -0
- package/scripts/publish-npm.js +174 -0
- package/spec-agent-implementation.md +750 -0
- package/src/commands/analyze.ts +322 -0
- package/src/commands/clean.ts +88 -0
- package/src/commands/dispatch.ts +250 -0
- package/src/commands/doctor.ts +136 -0
- package/src/commands/learn.ts +261 -0
- package/src/commands/merge.ts +377 -0
- package/src/commands/pipeline.ts +306 -0
- package/src/commands/plan.ts +331 -0
- package/src/commands/scan.ts +568 -0
- package/src/commands/status.ts +129 -0
- package/src/index.ts +137 -0
- package/src/services/document-parser.ts +548 -0
- package/src/services/llm.ts +857 -0
- package/src/types.ts +161 -0
- package/src/utils/file.ts +60 -0
- package/src/utils/logger.ts +58 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.statusCommand = statusCommand;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const logger_1 = require("../utils/logger");
|
|
39
|
+
const file_1 = require("../utils/file");
|
|
40
|
+
const PHASES = ['scan', 'analyze', 'merge', 'plan', 'dispatch'];
|
|
41
|
+
async function statusCommand(options, command) {
|
|
42
|
+
const logger = new logger_1.Logger();
|
|
43
|
+
const workspacePath = path.resolve(options.workspace);
|
|
44
|
+
try {
|
|
45
|
+
const status = await checkWorkspaceStatus(workspacePath);
|
|
46
|
+
if (options.format === 'json') {
|
|
47
|
+
logger.json(status);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Text output
|
|
51
|
+
logger.info(`Workspace: ${workspacePath}`);
|
|
52
|
+
logger.info('');
|
|
53
|
+
logger.info('Phases:');
|
|
54
|
+
for (const phase of PHASES) {
|
|
55
|
+
const phaseStatus = status.phases[phase];
|
|
56
|
+
const icon = phaseStatus.completed ? '✔' : '○';
|
|
57
|
+
let details = '';
|
|
58
|
+
if (phase === 'analyze' && 'chunksAnalyzed' in phaseStatus && phaseStatus.chunksAnalyzed !== undefined) {
|
|
59
|
+
details = `- ${phaseStatus.chunksAnalyzed} chunks analyzed`;
|
|
60
|
+
}
|
|
61
|
+
else if ('output' in phaseStatus && phaseStatus.output) {
|
|
62
|
+
details = `- ${phaseStatus.output}`;
|
|
63
|
+
}
|
|
64
|
+
logger.info(` ${icon} ${phase.padEnd(10)} ${details}`);
|
|
65
|
+
}
|
|
66
|
+
if (status.canResumeFrom) {
|
|
67
|
+
logger.info('');
|
|
68
|
+
logger.info(`Can resume from: ${status.canResumeFrom}`);
|
|
69
|
+
logger.info(` spec-agent pipeline --from ${status.canResumeFrom} --output ${options.workspace}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
logger.error(`Status check failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function checkWorkspaceStatus(workspacePath) {
|
|
78
|
+
const status = {
|
|
79
|
+
workspace: workspacePath,
|
|
80
|
+
phases: {
|
|
81
|
+
scan: { completed: false },
|
|
82
|
+
analyze: { completed: false },
|
|
83
|
+
merge: { completed: false },
|
|
84
|
+
plan: { completed: false },
|
|
85
|
+
dispatch: { completed: false },
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
// Check each phase
|
|
89
|
+
for (const phase of PHASES) {
|
|
90
|
+
const doneFile = path.join(workspacePath, `.${phase}_done`);
|
|
91
|
+
const phaseOutput = getPhaseOutput(phase);
|
|
92
|
+
const outputPath = path.join(workspacePath, phaseOutput);
|
|
93
|
+
const phaseState = status.phases[phase];
|
|
94
|
+
if (await (0, file_1.fileExists)(doneFile)) {
|
|
95
|
+
phaseState.completed = true;
|
|
96
|
+
if (phase !== 'analyze') {
|
|
97
|
+
phaseState.output = phaseOutput;
|
|
98
|
+
}
|
|
99
|
+
// Additional details for specific phases
|
|
100
|
+
if (phase === 'analyze') {
|
|
101
|
+
try {
|
|
102
|
+
const summariesDir = path.join(workspacePath, 'summaries');
|
|
103
|
+
const files = await Promise.resolve().then(() => __importStar(require('../utils/file'))).then(m => m.findFiles('chunk_*_summary.json', summariesDir));
|
|
104
|
+
phaseState.chunksAnalyzed = files.length;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Ignore errors
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (await (0, file_1.fileExists)(outputPath)) {
|
|
112
|
+
// Output exists but not marked done
|
|
113
|
+
phaseState.completed = true;
|
|
114
|
+
if (phase !== 'analyze') {
|
|
115
|
+
phaseState.output = phaseOutput;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Determine where we can resume from
|
|
120
|
+
for (let i = PHASES.length - 1; i >= 0; i--) {
|
|
121
|
+
const phase = PHASES[i];
|
|
122
|
+
if (status.phases[phase].completed) {
|
|
123
|
+
// Can resume from next phase
|
|
124
|
+
if (i < PHASES.length - 1) {
|
|
125
|
+
status.canResumeFrom = PHASES[i + 1];
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// If nothing done, can start from scan
|
|
131
|
+
if (!status.phases.scan.completed) {
|
|
132
|
+
status.canResumeFrom = 'scan';
|
|
133
|
+
}
|
|
134
|
+
return status;
|
|
135
|
+
}
|
|
136
|
+
function getPhaseOutput(phase) {
|
|
137
|
+
const outputs = {
|
|
138
|
+
scan: 'manifest.json',
|
|
139
|
+
analyze: 'summaries/',
|
|
140
|
+
merge: 'spec_summary.json',
|
|
141
|
+
plan: 'task_plan.json',
|
|
142
|
+
dispatch: 'dispatch_plan.json',
|
|
143
|
+
};
|
|
144
|
+
return outputs[phase];
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,sCAuCC;AArDD,2CAA6B;AAE7B,4CAAyC;AACzC,wCAAqD;AAQrD,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAU,CAAC;AAGlE,KAAK,UAAU,aAAa,CAAC,OAAsB,EAAE,OAAgB;IAC1E,MAAM,MAAM,GAAG,IAAI,eAAM,EAAE,CAAC;IAC5B,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,aAAa,CAAC,CAAC;QAEzD,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpB,OAAO;QACT,CAAC;QAED,cAAc;QACd,MAAM,CAAC,IAAI,CAAC,cAAc,aAAa,EAAE,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEvB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzC,MAAM,IAAI,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"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const scan_1 = require("./commands/scan");
|
|
5
|
+
const analyze_1 = require("./commands/analyze");
|
|
6
|
+
const merge_1 = require("./commands/merge");
|
|
7
|
+
const plan_1 = require("./commands/plan");
|
|
8
|
+
const dispatch_1 = require("./commands/dispatch");
|
|
9
|
+
const learn_1 = require("./commands/learn");
|
|
10
|
+
const pipeline_1 = require("./commands/pipeline");
|
|
11
|
+
const status_1 = require("./commands/status");
|
|
12
|
+
const clean_1 = require("./commands/clean");
|
|
13
|
+
const doctor_1 = require("./commands/doctor");
|
|
14
|
+
const program = new commander_1.Command();
|
|
15
|
+
program
|
|
16
|
+
.name('spec-agent')
|
|
17
|
+
.description('Multi-agent CLI tool for breaking down large requirement documents')
|
|
18
|
+
.version('1.0.0');
|
|
19
|
+
program
|
|
20
|
+
.command('scan')
|
|
21
|
+
.description('Scan documents and create chunk manifest')
|
|
22
|
+
.option('-i, --input <path>', 'Input file or directory')
|
|
23
|
+
.option('--stdin', 'Read file paths from stdin')
|
|
24
|
+
.option('-o, --output <path>', 'Output path for manifest.json', 'manifest.json')
|
|
25
|
+
.option('-c, --chunk-size <size>', 'Maximum chunk size for LLM analysis (default: 200kb)', '200kb')
|
|
26
|
+
.option('--min-chunk-size <size>', 'Minimum chunk size - smaller chunks will be merged (default: 10kb)', '10kb')
|
|
27
|
+
.option('--no-llm-chunking', 'Disable LLM-driven document structure analysis (use rule-based only)')
|
|
28
|
+
.option('--strict-llm', 'Fail if LLM chunking fails (no fallback)')
|
|
29
|
+
.option('-f, --format <format>', 'Input format: md, pdf, docx, html, auto', 'auto')
|
|
30
|
+
.option('--dry-run', 'Preview scan plan without creating manifest')
|
|
31
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
32
|
+
.action(scan_1.scanCommand);
|
|
33
|
+
program
|
|
34
|
+
.command('analyze')
|
|
35
|
+
.description('Analyze document chunks in parallel using multiple agents')
|
|
36
|
+
.option('-m, --manifest <path>', 'Path to manifest.json', 'manifest.json')
|
|
37
|
+
.option('-o, --output <dir>', 'Output directory for summaries', 'summaries')
|
|
38
|
+
.option('-a, --agents <count>', 'Number of parallel agents', 'auto')
|
|
39
|
+
.option('--chunks <indices>', 'Comma-separated chunk indices to analyze')
|
|
40
|
+
.option('--focus <type>', 'Analysis focus: full, features, data-model, api, pages', 'full')
|
|
41
|
+
.option('--apply-learned', 'Apply learned patterns from previous runs')
|
|
42
|
+
.option('--retries <count>', 'Retry attempts per failed chunk (default: 1)', '1')
|
|
43
|
+
.option('--budget-tokens <count>', 'Max total tokens for analyze run (0 = unlimited)', '0')
|
|
44
|
+
.option('--dry-run', 'Preview analysis plan without running')
|
|
45
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
46
|
+
.action(analyze_1.analyzeCommand);
|
|
47
|
+
program
|
|
48
|
+
.command('merge')
|
|
49
|
+
.description('Merge chunk summaries into unified spec')
|
|
50
|
+
.option('-s, --summaries <dir>', 'Directory containing summaries', 'summaries')
|
|
51
|
+
.option('-o, --output <path>', 'Output path for spec_summary.json', 'spec_summary.json')
|
|
52
|
+
.option('--strategy <strategy>', 'Merge strategy: conservative, aggressive', 'conservative')
|
|
53
|
+
.option('--dry-run', 'Preview merge plan without running')
|
|
54
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
55
|
+
.action(merge_1.mergeCommand);
|
|
56
|
+
program
|
|
57
|
+
.command('plan')
|
|
58
|
+
.description('Generate executable task plan from spec')
|
|
59
|
+
.option('-s, --spec <path>', 'Path to spec_summary.json', 'spec_summary.json')
|
|
60
|
+
.option('-o, --output <path>', 'Output path for task_plan.json', 'task_plan.json')
|
|
61
|
+
.option('-t, --type <type>', 'Output type: prototype, code, docs', 'prototype')
|
|
62
|
+
.option('--framework <fw>', 'Target framework: vue3, react, html', 'vue3')
|
|
63
|
+
.option('-p, --parallel <count>', 'Max parallel tasks', '3')
|
|
64
|
+
.option('--dry-run', 'Preview task plan without generating')
|
|
65
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
66
|
+
.action(plan_1.planCommand);
|
|
67
|
+
program
|
|
68
|
+
.command('dispatch')
|
|
69
|
+
.description('Dispatch tasks to specialized agents')
|
|
70
|
+
.option('-p, --plan <path>', 'Path to task_plan.json', 'task_plan.json')
|
|
71
|
+
.option('-o, --output <path>', 'Output path for dispatch_plan.json', 'dispatch_plan.json')
|
|
72
|
+
.option('-a, --agents <mapping>', 'Agent type mapping, e.g. frontend:2,backend:2')
|
|
73
|
+
.option('--strategy <strategy>', 'Dispatch strategy: balanced, skill-first, load-first', 'balanced')
|
|
74
|
+
.option('--dry-run', 'Preview dispatch plan without executing')
|
|
75
|
+
.option('-y, --yes', 'Skip confirmation prompts')
|
|
76
|
+
.action(dispatch_1.dispatchCommand);
|
|
77
|
+
program
|
|
78
|
+
.command('learn')
|
|
79
|
+
.description('Learn and accumulate project-specific patterns')
|
|
80
|
+
.option('-w, --workspace <dir>', 'Workspace directory', '.')
|
|
81
|
+
.option('--from <phase>', 'Learn from: summaries, plan, dispatch', 'summaries')
|
|
82
|
+
.option('--pattern <name>', 'Pattern name to learn')
|
|
83
|
+
.option('--rule <value>', 'Pattern rule value')
|
|
84
|
+
.option('--list', 'List all learned patterns')
|
|
85
|
+
.option('--export <path>', 'Export patterns to JSON file')
|
|
86
|
+
.option('--apply', 'Apply learned patterns to current workspace')
|
|
87
|
+
.action(learn_1.learnCommand);
|
|
88
|
+
program
|
|
89
|
+
.command('pipeline')
|
|
90
|
+
.description('Run full pipeline: scan → analyze → merge → plan → dispatch')
|
|
91
|
+
.option('-i, --input <path>', 'Input file or directory')
|
|
92
|
+
.option('-o, --output <dir>', 'Output directory', 'workspace')
|
|
93
|
+
.option('-a, --agents <count>', 'Max parallel agents', 'auto')
|
|
94
|
+
.option('-c, --chunk-size <size>', 'Max chunk size for LLM analysis (default: 200kb)', '200kb')
|
|
95
|
+
.option('--min-chunk-size <size>', 'Minimum chunk size - smaller chunks will be merged (default: 10kb)', '10kb')
|
|
96
|
+
.option('--analyze-retries <count>', 'Retry attempts per failed analyze chunk (default: 1)', '1')
|
|
97
|
+
.option('--analyze-budget-tokens <count>', 'Max total tokens for analyze in pipeline (0 = unlimited)', '0')
|
|
98
|
+
.option('--strict-llm', 'Fail if LLM chunking fails (no fallback)')
|
|
99
|
+
.option('--framework <fw>', 'Target framework', 'vue3')
|
|
100
|
+
.option('--stop-at <phase>', 'Stop after phase: scan, analyze, merge, plan, dispatch')
|
|
101
|
+
.option('--from <phase>', 'Resume from phase: scan, analyze, merge, plan, dispatch')
|
|
102
|
+
.option('--dry-run', 'Preview full pipeline without executing')
|
|
103
|
+
.option('-y, --yes', 'Skip all confirmation prompts')
|
|
104
|
+
.action(pipeline_1.pipelineCommand);
|
|
105
|
+
program
|
|
106
|
+
.command('status')
|
|
107
|
+
.description('Check workspace status')
|
|
108
|
+
.option('-w, --workspace <dir>', 'Workspace directory', '.')
|
|
109
|
+
.option('--format <format>', 'Output format: text, json', 'text')
|
|
110
|
+
.action(status_1.statusCommand);
|
|
111
|
+
program
|
|
112
|
+
.command('clean')
|
|
113
|
+
.description('Clean workspace intermediate files')
|
|
114
|
+
.option('-w, --workspace <dir>', 'Workspace directory', '.')
|
|
115
|
+
.option('--dry-run', 'Preview what would be cleaned')
|
|
116
|
+
.option('-y, --yes', 'Skip confirmation')
|
|
117
|
+
.action(clean_1.cleanCommand);
|
|
118
|
+
program
|
|
119
|
+
.command('doctor')
|
|
120
|
+
.description('Run environment and configuration health checks')
|
|
121
|
+
.option('-w, --workspace <dir>', 'Workspace directory', '.')
|
|
122
|
+
.option('--check-llm', 'Run a lightweight real LLM connectivity test')
|
|
123
|
+
.option('--format <format>', 'Output format: text, json', 'text')
|
|
124
|
+
.action(doctor_1.doctorCommand);
|
|
125
|
+
program.parse();
|
|
126
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,EAAE,GAAG,CAAC;KAC3D,MAAM,CAAC,aAAa,EAAE,8CAA8C,CAAC;KACrE,MAAM,CAAC,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,CAAC;KAChE,MAAM,CAAC,sBAAa,CAAC,CAAC;AAEzB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface ParsedDocument {
|
|
2
|
+
content: string;
|
|
3
|
+
format: 'markdown' | 'text' | 'html';
|
|
4
|
+
images?: EmbeddedImage[];
|
|
5
|
+
metadata: {
|
|
6
|
+
title?: string;
|
|
7
|
+
author?: string;
|
|
8
|
+
pages?: number;
|
|
9
|
+
wordCount?: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface EmbeddedImage {
|
|
13
|
+
id: string;
|
|
14
|
+
alt: string;
|
|
15
|
+
mimeType: string;
|
|
16
|
+
estimatedSize: number;
|
|
17
|
+
dataUri: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parse a document file and extract text content as Markdown
|
|
21
|
+
* Supports: .md, .txt, .html, .pdf, .docx
|
|
22
|
+
*
|
|
23
|
+
* All formats are normalized to Markdown for consistent chunking:
|
|
24
|
+
* - Headings become # ## ###
|
|
25
|
+
* - Lists become - or 1.
|
|
26
|
+
* - Tables become Markdown tables
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseDocument(filePath: string): Promise<ParsedDocument>;
|
|
29
|
+
export declare function extractEmbeddedImages(content: string): {
|
|
30
|
+
content: string;
|
|
31
|
+
images: EmbeddedImage[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Check if content contains base64 images and estimate their size
|
|
35
|
+
*/
|
|
36
|
+
export declare function analyzeBase64Images(content: string): {
|
|
37
|
+
count: number;
|
|
38
|
+
estimatedSize: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Read and concatenate multiple document files
|
|
42
|
+
* All content is normalized to Markdown format
|
|
43
|
+
*/
|
|
44
|
+
export declare function readChunkContent(filePaths: string[]): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a file format is supported
|
|
47
|
+
*/
|
|
48
|
+
export declare function isSupportedFormat(filePath: string): boolean;
|
|
49
|
+
//# sourceMappingURL=document-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-parser.d.ts","sourceRoot":"","sources":["../../src/services/document-parser.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;IACrC,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAoB7E;AAkDD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,EAAE,CAAA;CAAE,CAiCnG;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAe7F;AAqWD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB3E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG3D"}
|