archicore 0.1.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.
- package/README.md +530 -0
- package/dist/analyzers/dead-code.d.ts +95 -0
- package/dist/analyzers/dead-code.js +327 -0
- package/dist/analyzers/duplication.d.ts +90 -0
- package/dist/analyzers/duplication.js +344 -0
- package/dist/analyzers/security.d.ts +79 -0
- package/dist/analyzers/security.js +484 -0
- package/dist/architecture/index.d.ts +35 -0
- package/dist/architecture/index.js +249 -0
- package/dist/cli/commands/analyzers.d.ts +6 -0
- package/dist/cli/commands/analyzers.js +431 -0
- package/dist/cli/commands/export.d.ts +6 -0
- package/dist/cli/commands/export.js +78 -0
- package/dist/cli/commands/index.d.ts +8 -0
- package/dist/cli/commands/index.js +8 -0
- package/dist/cli/commands/init.d.ts +26 -0
- package/dist/cli/commands/init.js +140 -0
- package/dist/cli/commands/interactive.d.ts +7 -0
- package/dist/cli/commands/interactive.js +522 -0
- package/dist/cli/commands/projects.d.ts +6 -0
- package/dist/cli/commands/projects.js +249 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +7 -0
- package/dist/cli/ui/box.d.ts +17 -0
- package/dist/cli/ui/box.js +62 -0
- package/dist/cli/ui/colors.d.ts +49 -0
- package/dist/cli/ui/colors.js +86 -0
- package/dist/cli/ui/index.d.ts +9 -0
- package/dist/cli/ui/index.js +9 -0
- package/dist/cli/ui/prompt.d.ts +34 -0
- package/dist/cli/ui/prompt.js +122 -0
- package/dist/cli/ui/spinner.d.ts +29 -0
- package/dist/cli/ui/spinner.js +80 -0
- package/dist/cli/ui/table.d.ts +33 -0
- package/dist/cli/ui/table.js +84 -0
- package/dist/cli/utils/config.d.ts +23 -0
- package/dist/cli/utils/config.js +73 -0
- package/dist/cli/utils/index.d.ts +6 -0
- package/dist/cli/utils/index.js +6 -0
- package/dist/cli/utils/session.d.ts +27 -0
- package/dist/cli/utils/session.js +117 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +295 -0
- package/dist/code-index/ast-parser.d.ts +16 -0
- package/dist/code-index/ast-parser.js +330 -0
- package/dist/code-index/dependency-graph.d.ts +16 -0
- package/dist/code-index/dependency-graph.js +161 -0
- package/dist/code-index/index.d.ts +44 -0
- package/dist/code-index/index.js +124 -0
- package/dist/code-index/symbol-extractor.d.ts +13 -0
- package/dist/code-index/symbol-extractor.js +150 -0
- package/dist/export/index.d.ts +92 -0
- package/dist/export/index.js +676 -0
- package/dist/github/github-service.d.ts +146 -0
- package/dist/github/github-service.js +609 -0
- package/dist/impact-engine/index.d.ts +25 -0
- package/dist/impact-engine/index.js +284 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +149 -0
- package/dist/metrics/index.d.ts +136 -0
- package/dist/metrics/index.js +525 -0
- package/dist/orchestrator/deepseek-optimizer.d.ts +67 -0
- package/dist/orchestrator/deepseek-optimizer.js +320 -0
- package/dist/orchestrator/index.d.ts +34 -0
- package/dist/orchestrator/index.js +305 -0
- package/dist/pr-guardian/index.d.ts +143 -0
- package/dist/pr-guardian/index.js +553 -0
- package/dist/refactoring/index.d.ts +108 -0
- package/dist/refactoring/index.js +580 -0
- package/dist/rules-engine/index.d.ts +129 -0
- package/dist/rules-engine/index.js +482 -0
- package/dist/semantic-memory/embedding-service.d.ts +24 -0
- package/dist/semantic-memory/embedding-service.js +120 -0
- package/dist/semantic-memory/index.d.ts +45 -0
- package/dist/semantic-memory/index.js +206 -0
- package/dist/semantic-memory/vector-store.d.ts +27 -0
- package/dist/semantic-memory/vector-store.js +166 -0
- package/dist/server/index.d.ts +28 -0
- package/dist/server/index.js +141 -0
- package/dist/server/middleware/api-auth.d.ts +43 -0
- package/dist/server/middleware/api-auth.js +256 -0
- package/dist/server/routes/admin.d.ts +5 -0
- package/dist/server/routes/admin.js +123 -0
- package/dist/server/routes/api.d.ts +7 -0
- package/dist/server/routes/api.js +362 -0
- package/dist/server/routes/auth.d.ts +16 -0
- package/dist/server/routes/auth.js +191 -0
- package/dist/server/routes/developer.d.ts +8 -0
- package/dist/server/routes/developer.js +439 -0
- package/dist/server/routes/github.d.ts +7 -0
- package/dist/server/routes/github.js +495 -0
- package/dist/server/routes/upload.d.ts +7 -0
- package/dist/server/routes/upload.js +196 -0
- package/dist/server/services/api-key-service.d.ts +81 -0
- package/dist/server/services/api-key-service.js +281 -0
- package/dist/server/services/auth-service.d.ts +40 -0
- package/dist/server/services/auth-service.js +315 -0
- package/dist/server/services/project-service.d.ts +123 -0
- package/dist/server/services/project-service.js +533 -0
- package/dist/server/services/token-service.d.ts +107 -0
- package/dist/server/services/token-service.js +416 -0
- package/dist/server/services/upload-service.d.ts +93 -0
- package/dist/server/services/upload-service.js +464 -0
- package/dist/types/api.d.ts +188 -0
- package/dist/types/api.js +86 -0
- package/dist/types/github.d.ts +335 -0
- package/dist/types/github.js +5 -0
- package/dist/types/index.d.ts +265 -0
- package/dist/types/index.js +32 -0
- package/dist/types/user.d.ts +69 -0
- package/dist/types/user.js +42 -0
- package/dist/utils/file-utils.d.ts +20 -0
- package/dist/utils/file-utils.js +163 -0
- package/dist/utils/logger.d.ts +17 -0
- package/dist/utils/logger.js +41 -0
- package/dist/watcher/index.d.ts +125 -0
- package/dist/watcher/index.js +397 -0
- package/package.json +71 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiCore CLI Spinner Component
|
|
3
|
+
*/
|
|
4
|
+
export interface SpinnerOptions {
|
|
5
|
+
text: string;
|
|
6
|
+
color?: 'cyan' | 'green' | 'yellow' | 'red' | 'magenta' | 'blue' | 'white';
|
|
7
|
+
}
|
|
8
|
+
export declare class Spinner {
|
|
9
|
+
private spinner;
|
|
10
|
+
constructor(text: string);
|
|
11
|
+
start(text?: string): this;
|
|
12
|
+
update(text: string): this;
|
|
13
|
+
succeed(text?: string): this;
|
|
14
|
+
fail(text?: string): this;
|
|
15
|
+
warn(text?: string): this;
|
|
16
|
+
info(text?: string): this;
|
|
17
|
+
stop(): this;
|
|
18
|
+
}
|
|
19
|
+
export declare function createSpinner(text: string): Spinner;
|
|
20
|
+
export declare function withSpinner<T>(text: string, action: () => Promise<T>, options?: {
|
|
21
|
+
successText?: string;
|
|
22
|
+
failText?: string;
|
|
23
|
+
}): Promise<T>;
|
|
24
|
+
export declare function progressSteps(steps: string[]): {
|
|
25
|
+
next: () => void;
|
|
26
|
+
complete: () => void;
|
|
27
|
+
fail: (error?: string) => void;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiCore CLI Spinner Component
|
|
3
|
+
*/
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import { colors } from './colors.js';
|
|
6
|
+
export class Spinner {
|
|
7
|
+
spinner;
|
|
8
|
+
constructor(text) {
|
|
9
|
+
this.spinner = ora({
|
|
10
|
+
text: colors.muted(text),
|
|
11
|
+
spinner: 'dots',
|
|
12
|
+
color: 'magenta',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
start(text) {
|
|
16
|
+
if (text)
|
|
17
|
+
this.spinner.text = colors.muted(text);
|
|
18
|
+
this.spinner.start();
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
update(text) {
|
|
22
|
+
this.spinner.text = colors.muted(text);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
succeed(text) {
|
|
26
|
+
this.spinner.succeed(text ? colors.success(text) : undefined);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
fail(text) {
|
|
30
|
+
this.spinner.fail(text ? colors.error(text) : undefined);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
warn(text) {
|
|
34
|
+
this.spinner.warn(text ? colors.warning(text) : undefined);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
info(text) {
|
|
38
|
+
this.spinner.info(text ? colors.info(text) : undefined);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
stop() {
|
|
42
|
+
this.spinner.stop();
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function createSpinner(text) {
|
|
47
|
+
return new Spinner(text);
|
|
48
|
+
}
|
|
49
|
+
export async function withSpinner(text, action, options) {
|
|
50
|
+
const spinner = createSpinner(text).start();
|
|
51
|
+
try {
|
|
52
|
+
const result = await action();
|
|
53
|
+
spinner.succeed(options?.successText || text);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
spinner.fail(options?.failText || `Failed: ${text}`);
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function progressSteps(steps) {
|
|
62
|
+
let currentStep = 0;
|
|
63
|
+
const spinner = createSpinner(steps[0]).start();
|
|
64
|
+
return {
|
|
65
|
+
next: () => {
|
|
66
|
+
spinner.succeed();
|
|
67
|
+
currentStep++;
|
|
68
|
+
if (currentStep < steps.length) {
|
|
69
|
+
spinner.start(steps[currentStep]);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
complete: () => {
|
|
73
|
+
spinner.succeed();
|
|
74
|
+
},
|
|
75
|
+
fail: (error) => {
|
|
76
|
+
spinner.fail(error || steps[currentStep]);
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiCore CLI Table Components
|
|
3
|
+
*/
|
|
4
|
+
import Table from 'cli-table3';
|
|
5
|
+
export interface TableOptions {
|
|
6
|
+
head?: string[];
|
|
7
|
+
colWidths?: number[];
|
|
8
|
+
wordWrap?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function createTable(options?: TableOptions): Table.Table;
|
|
11
|
+
export declare function projectsTable(projects: Array<{
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
path: string;
|
|
15
|
+
status: string;
|
|
16
|
+
files?: number;
|
|
17
|
+
symbols?: number;
|
|
18
|
+
}>): string;
|
|
19
|
+
export declare function metricsTable(metrics: Array<{
|
|
20
|
+
file: string;
|
|
21
|
+
complexity: number;
|
|
22
|
+
maintainability: number;
|
|
23
|
+
linesOfCode: number;
|
|
24
|
+
}>): string;
|
|
25
|
+
export declare function issuesTable(issues: Array<{
|
|
26
|
+
severity: string;
|
|
27
|
+
type: string;
|
|
28
|
+
file: string;
|
|
29
|
+
line?: number;
|
|
30
|
+
message: string;
|
|
31
|
+
}>): string;
|
|
32
|
+
export declare function simpleTable(data: Array<[string, string]>): string;
|
|
33
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiCore CLI Table Components
|
|
3
|
+
*/
|
|
4
|
+
import Table from 'cli-table3';
|
|
5
|
+
import { colors } from './colors.js';
|
|
6
|
+
export function createTable(options = {}) {
|
|
7
|
+
const tableOptions = {
|
|
8
|
+
wordWrap: options.wordWrap ?? true,
|
|
9
|
+
};
|
|
10
|
+
if (options.head) {
|
|
11
|
+
tableOptions.head = options.head.map(h => colors.primary.bold(h));
|
|
12
|
+
}
|
|
13
|
+
if (options.colWidths) {
|
|
14
|
+
tableOptions.colWidths = options.colWidths;
|
|
15
|
+
}
|
|
16
|
+
return new Table(tableOptions);
|
|
17
|
+
}
|
|
18
|
+
export function projectsTable(projects) {
|
|
19
|
+
const table = createTable({
|
|
20
|
+
head: ['ID', 'Name', 'Path', 'Status', 'Files', 'Symbols'],
|
|
21
|
+
});
|
|
22
|
+
for (const project of projects) {
|
|
23
|
+
const statusColor = project.status === 'indexed' ? colors.success : colors.muted;
|
|
24
|
+
const id = project.id || 'unknown';
|
|
25
|
+
const name = project.name || 'Unnamed';
|
|
26
|
+
const path = project.path || '';
|
|
27
|
+
table.push([
|
|
28
|
+
colors.muted(id.slice(0, 8)),
|
|
29
|
+
colors.highlight(name),
|
|
30
|
+
colors.dim(path.length > 40 ? '...' + path.slice(-37) : path),
|
|
31
|
+
statusColor(project.status || 'unknown'),
|
|
32
|
+
colors.secondary(String(project.files || '-')),
|
|
33
|
+
colors.secondary(String(project.symbols || '-')),
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
return table.toString();
|
|
37
|
+
}
|
|
38
|
+
export function metricsTable(metrics) {
|
|
39
|
+
const table = createTable({
|
|
40
|
+
head: ['File', 'Complexity', 'Maintainability', 'LOC'],
|
|
41
|
+
});
|
|
42
|
+
for (const m of metrics) {
|
|
43
|
+
const complexityColor = m.complexity > 20 ? colors.error : m.complexity > 10 ? colors.warning : colors.success;
|
|
44
|
+
const maintColor = m.maintainability < 50 ? colors.error : m.maintainability < 70 ? colors.warning : colors.success;
|
|
45
|
+
table.push([
|
|
46
|
+
colors.dim(m.file.length > 50 ? '...' + m.file.slice(-47) : m.file),
|
|
47
|
+
complexityColor(String(m.complexity)),
|
|
48
|
+
maintColor(String(m.maintainability.toFixed(1))),
|
|
49
|
+
colors.muted(String(m.linesOfCode)),
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
return table.toString();
|
|
53
|
+
}
|
|
54
|
+
export function issuesTable(issues) {
|
|
55
|
+
const table = createTable({
|
|
56
|
+
head: ['Severity', 'Type', 'Location', 'Message'],
|
|
57
|
+
});
|
|
58
|
+
for (const issue of issues) {
|
|
59
|
+
const severityColor = {
|
|
60
|
+
critical: colors.critical,
|
|
61
|
+
high: colors.high,
|
|
62
|
+
medium: colors.medium,
|
|
63
|
+
low: colors.low,
|
|
64
|
+
}[issue.severity.toLowerCase()] || colors.muted;
|
|
65
|
+
const location = issue.line
|
|
66
|
+
? `${issue.file}:${issue.line}`
|
|
67
|
+
: issue.file;
|
|
68
|
+
table.push([
|
|
69
|
+
severityColor(issue.severity.toUpperCase()),
|
|
70
|
+
colors.secondary(issue.type),
|
|
71
|
+
colors.dim(location.length > 35 ? '...' + location.slice(-32) : location),
|
|
72
|
+
issue.message.slice(0, 50) + (issue.message.length > 50 ? '...' : ''),
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
return table.toString();
|
|
76
|
+
}
|
|
77
|
+
export function simpleTable(data) {
|
|
78
|
+
const lines = [];
|
|
79
|
+
for (const [key, value] of data) {
|
|
80
|
+
lines.push(` ${colors.muted(key + ':')} ${colors.highlight(value)}`);
|
|
81
|
+
}
|
|
82
|
+
return lines.join('\n');
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiCore CLI Configuration
|
|
3
|
+
*/
|
|
4
|
+
export interface CLIConfig {
|
|
5
|
+
activeProjectId?: string;
|
|
6
|
+
activeProjectPath?: string;
|
|
7
|
+
serverUrl: string;
|
|
8
|
+
colorOutput: boolean;
|
|
9
|
+
verboseOutput: boolean;
|
|
10
|
+
llmProvider?: 'openai' | 'anthropic' | 'deepseek';
|
|
11
|
+
llmModel?: string;
|
|
12
|
+
qdrantUrl: string;
|
|
13
|
+
qdrantApiKey?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function loadConfig(): Promise<CLIConfig>;
|
|
16
|
+
export declare function saveConfig(config: Partial<CLIConfig>): Promise<void>;
|
|
17
|
+
export declare function getConfigValue<K extends keyof CLIConfig>(key: K): Promise<CLIConfig[K]>;
|
|
18
|
+
export declare function setConfigValue<K extends keyof CLIConfig>(key: K, value: CLIConfig[K]): Promise<void>;
|
|
19
|
+
export declare function setActiveProject(projectId: string, projectPath: string): Promise<void>;
|
|
20
|
+
export declare function clearActiveProject(): Promise<void>;
|
|
21
|
+
export declare function getConfigDir(): string;
|
|
22
|
+
export declare function getConfigFile(): string;
|
|
23
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiCore CLI Configuration
|
|
3
|
+
*/
|
|
4
|
+
import { readFile, writeFile, mkdir } from 'fs/promises';
|
|
5
|
+
import { homedir } from 'os';
|
|
6
|
+
import { join } from 'path';
|
|
7
|
+
const CONFIG_DIR = join(homedir(), '.archicore');
|
|
8
|
+
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
9
|
+
const DEFAULT_CONFIG = {
|
|
10
|
+
serverUrl: 'http://127.0.0.1:3000',
|
|
11
|
+
colorOutput: true,
|
|
12
|
+
verboseOutput: false,
|
|
13
|
+
qdrantUrl: 'http://127.0.0.1:6333',
|
|
14
|
+
};
|
|
15
|
+
let cachedConfig = null;
|
|
16
|
+
export async function loadConfig() {
|
|
17
|
+
if (cachedConfig)
|
|
18
|
+
return cachedConfig;
|
|
19
|
+
let config;
|
|
20
|
+
try {
|
|
21
|
+
await mkdir(CONFIG_DIR, { recursive: true });
|
|
22
|
+
const data = await readFile(CONFIG_FILE, 'utf-8');
|
|
23
|
+
config = { ...DEFAULT_CONFIG, ...JSON.parse(data) };
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
config = { ...DEFAULT_CONFIG };
|
|
27
|
+
}
|
|
28
|
+
// Override with environment variables
|
|
29
|
+
if (process.env.ARCHICORE_SERVER_URL) {
|
|
30
|
+
config.serverUrl = process.env.ARCHICORE_SERVER_URL;
|
|
31
|
+
}
|
|
32
|
+
if (process.env.QDRANT_URL) {
|
|
33
|
+
config.qdrantUrl = process.env.QDRANT_URL;
|
|
34
|
+
}
|
|
35
|
+
if (process.env.QDRANT_API_KEY) {
|
|
36
|
+
config.qdrantApiKey = process.env.QDRANT_API_KEY;
|
|
37
|
+
}
|
|
38
|
+
cachedConfig = config;
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
export async function saveConfig(config) {
|
|
42
|
+
const current = await loadConfig();
|
|
43
|
+
const updated = { ...current, ...config };
|
|
44
|
+
await mkdir(CONFIG_DIR, { recursive: true });
|
|
45
|
+
await writeFile(CONFIG_FILE, JSON.stringify(updated, null, 2));
|
|
46
|
+
cachedConfig = updated;
|
|
47
|
+
}
|
|
48
|
+
export async function getConfigValue(key) {
|
|
49
|
+
const config = await loadConfig();
|
|
50
|
+
return config[key];
|
|
51
|
+
}
|
|
52
|
+
export async function setConfigValue(key, value) {
|
|
53
|
+
await saveConfig({ [key]: value });
|
|
54
|
+
}
|
|
55
|
+
export async function setActiveProject(projectId, projectPath) {
|
|
56
|
+
await saveConfig({
|
|
57
|
+
activeProjectId: projectId,
|
|
58
|
+
activeProjectPath: projectPath,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export async function clearActiveProject() {
|
|
62
|
+
await saveConfig({
|
|
63
|
+
activeProjectId: undefined,
|
|
64
|
+
activeProjectPath: undefined,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function getConfigDir() {
|
|
68
|
+
return CONFIG_DIR;
|
|
69
|
+
}
|
|
70
|
+
export function getConfigFile() {
|
|
71
|
+
return CONFIG_FILE;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiCore CLI Session Management
|
|
3
|
+
*/
|
|
4
|
+
export interface ProjectInfo {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
path: string;
|
|
8
|
+
status: string;
|
|
9
|
+
files?: number;
|
|
10
|
+
symbols?: number;
|
|
11
|
+
indexed?: boolean;
|
|
12
|
+
lastIndexed?: Date;
|
|
13
|
+
}
|
|
14
|
+
export interface SessionState {
|
|
15
|
+
project: ProjectInfo | null;
|
|
16
|
+
serverUrl: string;
|
|
17
|
+
connected: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function initSession(): Promise<SessionState>;
|
|
20
|
+
export declare function getSession(): SessionState | null;
|
|
21
|
+
export declare function selectProject(projectId: string): Promise<ProjectInfo | null>;
|
|
22
|
+
export declare function clearProject(): Promise<void>;
|
|
23
|
+
export declare function fetchProjects(): Promise<ProjectInfo[]>;
|
|
24
|
+
export declare function checkServerConnection(): Promise<boolean>;
|
|
25
|
+
export declare function requireProject(): ProjectInfo;
|
|
26
|
+
export declare function requireConnection(): void;
|
|
27
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArchiCore CLI Session Management
|
|
3
|
+
*/
|
|
4
|
+
import { loadConfig, setActiveProject } from './config.js';
|
|
5
|
+
let sessionState = null;
|
|
6
|
+
export async function initSession() {
|
|
7
|
+
const config = await loadConfig();
|
|
8
|
+
sessionState = {
|
|
9
|
+
project: null,
|
|
10
|
+
serverUrl: config.serverUrl,
|
|
11
|
+
connected: false,
|
|
12
|
+
};
|
|
13
|
+
// Try to load active project
|
|
14
|
+
if (config.activeProjectId) {
|
|
15
|
+
try {
|
|
16
|
+
const project = await fetchProject(config.activeProjectId);
|
|
17
|
+
if (project) {
|
|
18
|
+
sessionState.project = project;
|
|
19
|
+
sessionState.connected = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// Project not found or server not available
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return sessionState;
|
|
27
|
+
}
|
|
28
|
+
export function getSession() {
|
|
29
|
+
return sessionState;
|
|
30
|
+
}
|
|
31
|
+
export async function selectProject(projectId) {
|
|
32
|
+
const project = await fetchProject(projectId);
|
|
33
|
+
if (project && sessionState) {
|
|
34
|
+
sessionState.project = project;
|
|
35
|
+
await setActiveProject(project.id, project.path);
|
|
36
|
+
}
|
|
37
|
+
return project;
|
|
38
|
+
}
|
|
39
|
+
export async function clearProject() {
|
|
40
|
+
if (sessionState) {
|
|
41
|
+
sessionState.project = null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function fetchProject(projectId) {
|
|
45
|
+
const config = await loadConfig();
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(`${config.serverUrl}/api/projects/${projectId}`);
|
|
48
|
+
if (!response.ok)
|
|
49
|
+
return null;
|
|
50
|
+
const data = await response.json();
|
|
51
|
+
return {
|
|
52
|
+
id: data.id,
|
|
53
|
+
name: data.name,
|
|
54
|
+
path: data.path,
|
|
55
|
+
status: data.status || 'unknown',
|
|
56
|
+
files: data.statistics?.codeIndex?.totalFiles,
|
|
57
|
+
symbols: data.statistics?.codeIndex?.totalSymbols,
|
|
58
|
+
indexed: data.status === 'indexed',
|
|
59
|
+
lastIndexed: data.lastIndexed ? new Date(data.lastIndexed) : undefined,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export async function fetchProjects() {
|
|
67
|
+
const config = await loadConfig();
|
|
68
|
+
try {
|
|
69
|
+
const response = await fetch(`${config.serverUrl}/api/projects`);
|
|
70
|
+
if (!response.ok)
|
|
71
|
+
return [];
|
|
72
|
+
const data = await response.json();
|
|
73
|
+
return (data.projects || []).map((p) => ({
|
|
74
|
+
id: p.id,
|
|
75
|
+
name: p.name,
|
|
76
|
+
path: p.path,
|
|
77
|
+
status: p.status || 'unknown',
|
|
78
|
+
files: p.stats?.filesCount || p.statistics?.codeIndex?.totalFiles,
|
|
79
|
+
symbols: p.stats?.symbolsCount || p.statistics?.codeIndex?.totalSymbols,
|
|
80
|
+
indexed: p.status === 'ready' || p.status === 'indexed',
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export async function checkServerConnection() {
|
|
88
|
+
const config = await loadConfig();
|
|
89
|
+
try {
|
|
90
|
+
const response = await fetch(`${config.serverUrl}/health`, {
|
|
91
|
+
signal: AbortSignal.timeout(5000),
|
|
92
|
+
});
|
|
93
|
+
const connected = response.ok;
|
|
94
|
+
if (sessionState) {
|
|
95
|
+
sessionState.connected = connected;
|
|
96
|
+
}
|
|
97
|
+
return connected;
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
if (sessionState) {
|
|
101
|
+
sessionState.connected = false;
|
|
102
|
+
}
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export function requireProject() {
|
|
107
|
+
if (!sessionState?.project) {
|
|
108
|
+
throw new Error('No project selected. Use "archicore projects select <id>" first.');
|
|
109
|
+
}
|
|
110
|
+
return sessionState.project;
|
|
111
|
+
}
|
|
112
|
+
export function requireConnection() {
|
|
113
|
+
if (!sessionState?.connected) {
|
|
114
|
+
throw new Error('Not connected to ArchiCore server. Make sure the server is running.');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=session.js.map
|