@sudosandwich/limps 3.1.1 → 3.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.
- package/README.md +114 -23
- package/dist/agent-parser.d.ts +1 -1
- package/dist/agent-parser.d.ts.map +1 -1
- package/dist/agent-parser.js +8 -4
- package/dist/agent-parser.js.map +1 -1
- package/dist/cli/config-cmd.d.ts +2 -2
- package/dist/cli/config-cmd.js +5 -5
- package/dist/cli/config-cmd.js.map +1 -1
- package/dist/cli/docs-create.d.ts +34 -0
- package/dist/cli/docs-create.d.ts.map +1 -0
- package/dist/cli/docs-create.js +70 -0
- package/dist/cli/docs-create.js.map +1 -0
- package/dist/cli/docs-delete.d.ts +34 -0
- package/dist/cli/docs-delete.d.ts.map +1 -0
- package/dist/cli/docs-delete.js +84 -0
- package/dist/cli/docs-delete.js.map +1 -0
- package/dist/cli/docs-list.d.ts +35 -0
- package/dist/cli/docs-list.d.ts.map +1 -0
- package/dist/cli/docs-list.js +91 -0
- package/dist/cli/docs-list.js.map +1 -0
- package/dist/cli/docs-search.d.ts +35 -0
- package/dist/cli/docs-search.d.ts.map +1 -0
- package/dist/cli/docs-search.js +99 -0
- package/dist/cli/docs-search.js.map +1 -0
- package/dist/cli/docs-update.d.ts +40 -0
- package/dist/cli/docs-update.d.ts.map +1 -0
- package/dist/cli/docs-update.js +75 -0
- package/dist/cli/docs-update.js.map +1 -0
- package/dist/cli/init-project.js +1 -1
- package/dist/cli/mcp-client-adapter.d.ts +26 -17
- package/dist/cli/mcp-client-adapter.d.ts.map +1 -1
- package/dist/cli/mcp-client-adapter.js +23 -28
- package/dist/cli/mcp-client-adapter.js.map +1 -1
- package/dist/cli/status.d.ts +13 -0
- package/dist/cli/status.d.ts.map +1 -1
- package/dist/cli/status.js +64 -1
- package/dist/cli/status.js.map +1 -1
- package/dist/cli.js +9 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/config/index.d.ts.map +1 -1
- package/dist/commands/config/index.js +1 -0
- package/dist/commands/config/index.js.map +1 -1
- package/dist/commands/config/show-resolution.d.ts +11 -0
- package/dist/commands/config/show-resolution.d.ts.map +1 -0
- package/dist/commands/config/show-resolution.js +114 -0
- package/dist/commands/config/show-resolution.js.map +1 -0
- package/dist/commands/create-doc.d.ts +21 -0
- package/dist/commands/create-doc.d.ts.map +1 -0
- package/dist/commands/create-doc.js +99 -0
- package/dist/commands/create-doc.js.map +1 -0
- package/dist/commands/create-plan.d.ts +15 -0
- package/dist/commands/create-plan.d.ts.map +1 -0
- package/dist/commands/create-plan.js +73 -0
- package/dist/commands/create-plan.js.map +1 -0
- package/dist/commands/delete-doc.d.ts +16 -0
- package/dist/commands/delete-doc.d.ts.map +1 -0
- package/dist/commands/delete-doc.js +97 -0
- package/dist/commands/delete-doc.js.map +1 -0
- package/dist/commands/index.js +1 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/list-docs.d.ts +18 -0
- package/dist/commands/list-docs.d.ts.map +1 -0
- package/dist/commands/list-docs.js +83 -0
- package/dist/commands/list-docs.js.map +1 -0
- package/dist/commands/process.d.ts +20 -0
- package/dist/commands/process.d.ts.map +1 -0
- package/dist/commands/process.js +257 -0
- package/dist/commands/process.js.map +1 -0
- package/dist/commands/search-docs.d.ts +17 -0
- package/dist/commands/search-docs.d.ts.map +1 -0
- package/dist/commands/search-docs.js +109 -0
- package/dist/commands/search-docs.js.map +1 -0
- package/dist/commands/serve.d.ts +17 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +125 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/{status-server.d.ts → server-status.d.ts} +1 -1
- package/dist/commands/server-status.d.ts.map +1 -0
- package/dist/commands/{status-server.js → server-status.js} +33 -14
- package/dist/commands/server-status.js.map +1 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +26 -9
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/status.d.ts +7 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +74 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/tags/add.d.ts +16 -0
- package/dist/commands/tags/add.d.ts.map +1 -0
- package/dist/commands/tags/add.js +120 -0
- package/dist/commands/tags/add.js.map +1 -0
- package/dist/commands/tags/index.d.ts +3 -0
- package/dist/commands/tags/index.d.ts.map +1 -0
- package/dist/commands/tags/index.js +33 -0
- package/dist/commands/tags/index.js.map +1 -0
- package/dist/commands/tags/list.d.ts +15 -0
- package/dist/commands/tags/list.d.ts.map +1 -0
- package/dist/commands/tags/list.js +111 -0
- package/dist/commands/tags/list.js.map +1 -0
- package/dist/commands/tags/remove.d.ts +16 -0
- package/dist/commands/tags/remove.d.ts.map +1 -0
- package/dist/commands/tags/remove.js +120 -0
- package/dist/commands/tags/remove.js.map +1 -0
- package/dist/commands/update-doc.d.ts +23 -0
- package/dist/commands/update-doc.d.ts.map +1 -0
- package/dist/commands/update-doc.js +144 -0
- package/dist/commands/update-doc.js.map +1 -0
- package/dist/extensions/context.d.ts.map +1 -1
- package/dist/extensions/context.js +10 -8
- package/dist/extensions/context.js.map +1 -1
- package/dist/extensions/loader.d.ts.map +1 -1
- package/dist/extensions/loader.js +3 -2
- package/dist/extensions/loader.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/pidfile.d.ts +1 -0
- package/dist/pidfile.d.ts.map +1 -1
- package/dist/pidfile.js +4 -1
- package/dist/pidfile.js.map +1 -1
- package/dist/server-http-entry.js +39 -6
- package/dist/server-http-entry.js.map +1 -1
- package/dist/server-http.d.ts +11 -1
- package/dist/server-http.d.ts.map +1 -1
- package/dist/server-http.js +44 -9
- package/dist/server-http.js.map +1 -1
- package/dist/server-main.d.ts.map +1 -1
- package/dist/server-main.js +2 -1
- package/dist/server-main.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +10 -8
- package/dist/server.js.map +1 -1
- package/dist/tools/create-plan.d.ts +1 -0
- package/dist/tools/create-plan.d.ts.map +1 -1
- package/dist/tools/create-plan.js +20 -6
- package/dist/tools/create-plan.js.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/update-task-status.d.ts +1 -1
- package/dist/tools/update-task-status.d.ts.map +1 -1
- package/dist/tools/update-task-status.js +17 -187
- package/dist/tools/update-task-status.js.map +1 -1
- package/dist/utils/config-resolver.d.ts +1 -1
- package/dist/utils/config-resolver.d.ts.map +1 -1
- package/dist/utils/config-resolver.js +6 -4
- package/dist/utils/config-resolver.js.map +1 -1
- package/dist/utils/daemon-log.d.ts +13 -0
- package/dist/utils/daemon-log.d.ts.map +1 -0
- package/dist/utils/daemon-log.js +27 -0
- package/dist/utils/daemon-log.js.map +1 -0
- package/dist/utils/daemon-manager.d.ts +23 -0
- package/dist/utils/daemon-manager.d.ts.map +1 -0
- package/dist/utils/daemon-manager.js +89 -0
- package/dist/utils/daemon-manager.js.map +1 -0
- package/dist/utils/http-client.d.ts +2 -0
- package/dist/utils/http-client.d.ts.map +1 -1
- package/dist/utils/http-client.js.map +1 -1
- package/dist/utils/safe-logging.d.ts +24 -0
- package/dist/utils/safe-logging.d.ts.map +1 -0
- package/dist/utils/safe-logging.js +88 -0
- package/dist/utils/safe-logging.js.map +1 -0
- package/package.json +3 -1
- package/postinstall/postinstall.cjs +354 -0
- package/dist/commands/status-server.d.ts.map +0 -1
- package/dist/commands/status-server.js.map +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: delete-doc
|
|
3
|
+
* Delete documents with confirmation and backup.
|
|
4
|
+
*/
|
|
5
|
+
import type { ServerConfig } from '../config.js';
|
|
6
|
+
import type { DeleteDocOutput } from '../tools/delete-doc.js';
|
|
7
|
+
/**
|
|
8
|
+
* Options for deleting documents.
|
|
9
|
+
*/
|
|
10
|
+
export interface DeleteDocOptions {
|
|
11
|
+
path: string;
|
|
12
|
+
confirm?: boolean;
|
|
13
|
+
permanent?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get document deletion result from the tool handler.
|
|
17
|
+
* Returns structured data for rendering.
|
|
18
|
+
*
|
|
19
|
+
* @param config - Server configuration
|
|
20
|
+
* @param options - Deletion options
|
|
21
|
+
* @returns Deletion result or error message
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDeleteDocData(config: ServerConfig, options: DeleteDocOptions): Promise<DeleteDocOutput | {
|
|
24
|
+
error: string;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete a document.
|
|
28
|
+
*
|
|
29
|
+
* @param config - Server configuration
|
|
30
|
+
* @param options - Deletion options
|
|
31
|
+
* @returns Formatted string output for CLI
|
|
32
|
+
*/
|
|
33
|
+
export declare function deleteDoc(config: ServerConfig, options: DeleteDocOptions): Promise<string>;
|
|
34
|
+
//# sourceMappingURL=docs-delete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-delete.d.ts","sourceRoot":"","sources":["../../src/cli/docs-delete.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,wBAAwB,CAAC;AAM9E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CA8B9C;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmChG"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: delete-doc
|
|
3
|
+
* Delete documents with confirmation and backup.
|
|
4
|
+
*/
|
|
5
|
+
import { handleDeleteDoc } from '../tools/delete-doc.js';
|
|
6
|
+
import { initializeDatabase, createSchema } from '../indexer.js';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import { mkdirSync } from 'fs';
|
|
9
|
+
/**
|
|
10
|
+
* Get document deletion result from the tool handler.
|
|
11
|
+
* Returns structured data for rendering.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Server configuration
|
|
14
|
+
* @param options - Deletion options
|
|
15
|
+
* @returns Deletion result or error message
|
|
16
|
+
*/
|
|
17
|
+
export async function getDeleteDocData(config, options) {
|
|
18
|
+
// Ensure data directory exists
|
|
19
|
+
mkdirSync(config.dataPath, { recursive: true });
|
|
20
|
+
const dbPath = resolve(config.dataPath, 'documents.sqlite');
|
|
21
|
+
const db = initializeDatabase(dbPath);
|
|
22
|
+
try {
|
|
23
|
+
createSchema(db);
|
|
24
|
+
const input = {
|
|
25
|
+
path: options.path,
|
|
26
|
+
confirm: options.confirm || false,
|
|
27
|
+
permanent: options.permanent || false,
|
|
28
|
+
};
|
|
29
|
+
const result = await handleDeleteDoc(input, { config, db });
|
|
30
|
+
if (result.isError) {
|
|
31
|
+
const errorText = result.content[0]?.text || 'Unknown error';
|
|
32
|
+
return { error: errorText };
|
|
33
|
+
}
|
|
34
|
+
const data = JSON.parse(result.content[0].text);
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return {
|
|
39
|
+
error: error instanceof Error ? error.message : String(error),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
db.close();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Delete a document.
|
|
48
|
+
*
|
|
49
|
+
* @param config - Server configuration
|
|
50
|
+
* @param options - Deletion options
|
|
51
|
+
* @returns Formatted string output for CLI
|
|
52
|
+
*/
|
|
53
|
+
export async function deleteDoc(config, options) {
|
|
54
|
+
const result = await getDeleteDocData(config, options);
|
|
55
|
+
if ('error' in result) {
|
|
56
|
+
return `Error: ${result.error}`;
|
|
57
|
+
}
|
|
58
|
+
const lines = [];
|
|
59
|
+
if (result.pending) {
|
|
60
|
+
lines.push('⚠️ Deletion pending confirmation');
|
|
61
|
+
lines.push('');
|
|
62
|
+
lines.push(`Path: ${result.path}`);
|
|
63
|
+
if (result.preview) {
|
|
64
|
+
lines.push('');
|
|
65
|
+
lines.push('Preview:');
|
|
66
|
+
lines.push(result.preview);
|
|
67
|
+
}
|
|
68
|
+
lines.push('');
|
|
69
|
+
lines.push('Run with --confirm to proceed');
|
|
70
|
+
}
|
|
71
|
+
else if (result.deleted) {
|
|
72
|
+
lines.push('✓ Document deleted successfully');
|
|
73
|
+
lines.push('');
|
|
74
|
+
lines.push(`Path: ${result.path}`);
|
|
75
|
+
if (result.trash) {
|
|
76
|
+
lines.push(`Moved to trash: ${result.trash}`);
|
|
77
|
+
}
|
|
78
|
+
if (result.backup) {
|
|
79
|
+
lines.push(`Backup: ${result.backup}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return lines.join('\n');
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=docs-delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-delete.js","sourceRoot":"","sources":["../../src/cli/docs-delete.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAW/B;;;;;;;GAOG;AACH,MAAM,CAAC,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AE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: list-docs
|
|
3
|
+
* Lists files and directories with optional filtering.
|
|
4
|
+
*/
|
|
5
|
+
import type { ServerConfig } from '../config.js';
|
|
6
|
+
import type { ListDocsOutput } from '../tools/list-docs.js';
|
|
7
|
+
/**
|
|
8
|
+
* Options for listing documents.
|
|
9
|
+
*/
|
|
10
|
+
export interface ListDocsOptions {
|
|
11
|
+
path?: string;
|
|
12
|
+
pattern?: string;
|
|
13
|
+
depth?: number;
|
|
14
|
+
includeHidden?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get documents list data from the tool handler.
|
|
18
|
+
* Returns structured data for rendering.
|
|
19
|
+
*
|
|
20
|
+
* @param config - Server configuration
|
|
21
|
+
* @param options - Listing options
|
|
22
|
+
* @returns List data or error message
|
|
23
|
+
*/
|
|
24
|
+
export declare function getDocsListData(config: ServerConfig, options?: ListDocsOptions): Promise<ListDocsOutput | {
|
|
25
|
+
error: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* List documents from the configured paths.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Server configuration
|
|
31
|
+
* @param options - Listing options
|
|
32
|
+
* @returns Formatted string output for CLI
|
|
33
|
+
*/
|
|
34
|
+
export declare function listDocs(config: ServerConfig, options?: ListDocsOptions): Promise<string>;
|
|
35
|
+
//# sourceMappingURL=docs-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-list.d.ts","sourceRoot":"","sources":["../../src/cli/docs-list.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAY,MAAM,uBAAuB,CAAC;AAMtE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAiC7C;AAqBD;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAuBjB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: list-docs
|
|
3
|
+
* Lists files and directories with optional filtering.
|
|
4
|
+
*/
|
|
5
|
+
import { handleListDocs } from '../tools/list-docs.js';
|
|
6
|
+
import { initializeDatabase, createSchema } from '../indexer.js';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import { mkdirSync } from 'fs';
|
|
9
|
+
/**
|
|
10
|
+
* Get documents list data from the tool handler.
|
|
11
|
+
* Returns structured data for rendering.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Server configuration
|
|
14
|
+
* @param options - Listing options
|
|
15
|
+
* @returns List data or error message
|
|
16
|
+
*/
|
|
17
|
+
export async function getDocsListData(config, options = {}) {
|
|
18
|
+
// Ensure data directory exists
|
|
19
|
+
mkdirSync(config.dataPath, { recursive: true });
|
|
20
|
+
const dbPath = resolve(config.dataPath, 'documents.sqlite');
|
|
21
|
+
const db = initializeDatabase(dbPath);
|
|
22
|
+
try {
|
|
23
|
+
createSchema(db);
|
|
24
|
+
const result = await handleListDocs({
|
|
25
|
+
path: options.path || '',
|
|
26
|
+
pattern: options.pattern,
|
|
27
|
+
depth: options.depth || 2,
|
|
28
|
+
includeHidden: options.includeHidden || false,
|
|
29
|
+
prettyPrint: true,
|
|
30
|
+
}, { config, db });
|
|
31
|
+
if (result.isError) {
|
|
32
|
+
const errorText = result.content[0]?.text || 'Unknown error';
|
|
33
|
+
return { error: errorText };
|
|
34
|
+
}
|
|
35
|
+
const data = JSON.parse(result.content[0].text);
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return {
|
|
40
|
+
error: error instanceof Error ? error.message : String(error),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
db.close();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Format directory entry for CLI display.
|
|
49
|
+
*/
|
|
50
|
+
function formatEntry(entry, indent = 0) {
|
|
51
|
+
const prefix = ' '.repeat(indent);
|
|
52
|
+
const icon = entry.type === 'directory' ? '📁' : '📄';
|
|
53
|
+
let line = `${prefix}${icon} ${entry.name}`;
|
|
54
|
+
if (entry.type === 'file' && entry.size !== undefined) {
|
|
55
|
+
const sizeKb = (entry.size / 1024).toFixed(1);
|
|
56
|
+
line += ` (${sizeKb} KB)`;
|
|
57
|
+
}
|
|
58
|
+
else if (entry.type === 'directory' && entry.children !== undefined) {
|
|
59
|
+
line += ` (${entry.children} items)`;
|
|
60
|
+
}
|
|
61
|
+
return line;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* List documents from the configured paths.
|
|
65
|
+
*
|
|
66
|
+
* @param config - Server configuration
|
|
67
|
+
* @param options - Listing options
|
|
68
|
+
* @returns Formatted string output for CLI
|
|
69
|
+
*/
|
|
70
|
+
export async function listDocs(config, options = {}) {
|
|
71
|
+
const result = await getDocsListData(config, options);
|
|
72
|
+
if ('error' in result) {
|
|
73
|
+
return `Error: ${result.error}`;
|
|
74
|
+
}
|
|
75
|
+
const lines = [];
|
|
76
|
+
const displayPath = result.path || '(root)';
|
|
77
|
+
lines.push(`Documents in: ${displayPath}`);
|
|
78
|
+
lines.push('');
|
|
79
|
+
if (result.entries.length === 0) {
|
|
80
|
+
lines.push('No files found');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
for (const entry of result.entries) {
|
|
84
|
+
lines.push(formatEntry(entry));
|
|
85
|
+
}
|
|
86
|
+
lines.push('');
|
|
87
|
+
lines.push(`Total: ${result.total} item(s)`);
|
|
88
|
+
}
|
|
89
|
+
return lines.join('\n');
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=docs-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-list.js","sourceRoot":"","sources":["../../src/cli/docs-list.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAY/B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAoB,EACpB,UAA2B,EAAE;IAE7B,+BAA+B;IAC/B,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAEtC,IAAI,CAAC;QACH,YAAY,CAAC,EAAE,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,MAAM,cAAc,CACjC;YACE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,C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|
|
1
|
+
/**
|
|
2
|
+
* CLI command: search-docs
|
|
3
|
+
* Full-text search across planning documents.
|
|
4
|
+
*/
|
|
5
|
+
import type { ServerConfig } from '../config.js';
|
|
6
|
+
import type { SearchResult } from '../tools/search-docs.js';
|
|
7
|
+
/**
|
|
8
|
+
* Options for searching documents.
|
|
9
|
+
*/
|
|
10
|
+
export interface SearchDocsOptions {
|
|
11
|
+
query: string;
|
|
12
|
+
limit?: number;
|
|
13
|
+
searchFrontmatter?: boolean;
|
|
14
|
+
caseSensitive?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get search results data from the tool handler.
|
|
18
|
+
* Returns structured data for rendering.
|
|
19
|
+
*
|
|
20
|
+
* @param config - Server configuration
|
|
21
|
+
* @param options - Search options
|
|
22
|
+
* @returns Search results or error message
|
|
23
|
+
*/
|
|
24
|
+
export declare function getSearchDocsData(config: ServerConfig, options: SearchDocsOptions): Promise<SearchResult[] | {
|
|
25
|
+
error: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Search documents using full-text search.
|
|
29
|
+
*
|
|
30
|
+
* @param config - Server configuration
|
|
31
|
+
* @param options - Search options
|
|
32
|
+
* @returns Formatted string output for CLI
|
|
33
|
+
*/
|
|
34
|
+
export declare function searchDocs(config: ServerConfig, options: SearchDocsOptions): Promise<string>;
|
|
35
|
+
//# sourceMappingURL=docs-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search.d.ts","sourceRoot":"","sources":["../../src/cli/docs-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAM5D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,YAAY,EAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAyC7C;AAqBD;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,MAAM,CAAC,CAyBjB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: search-docs
|
|
3
|
+
* Full-text search across planning documents.
|
|
4
|
+
*/
|
|
5
|
+
import { handleSearchDocs } from '../tools/search-docs.js';
|
|
6
|
+
import { initializeDatabase, createSchema } from '../indexer.js';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import { mkdirSync } from 'fs';
|
|
9
|
+
/**
|
|
10
|
+
* Get search results data from the tool handler.
|
|
11
|
+
* Returns structured data for rendering.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Server configuration
|
|
14
|
+
* @param options - Search options
|
|
15
|
+
* @returns Search results or error message
|
|
16
|
+
*/
|
|
17
|
+
export async function getSearchDocsData(config, options) {
|
|
18
|
+
// Ensure data directory exists
|
|
19
|
+
mkdirSync(config.dataPath, { recursive: true });
|
|
20
|
+
const dbPath = resolve(config.dataPath, 'documents.sqlite');
|
|
21
|
+
const db = initializeDatabase(dbPath);
|
|
22
|
+
try {
|
|
23
|
+
createSchema(db);
|
|
24
|
+
const result = await handleSearchDocs({
|
|
25
|
+
query: options.query,
|
|
26
|
+
limit: options.limit || 20,
|
|
27
|
+
searchContent: true,
|
|
28
|
+
searchFrontmatter: options.searchFrontmatter || false,
|
|
29
|
+
caseSensitive: options.caseSensitive || false,
|
|
30
|
+
prettyPrint: true,
|
|
31
|
+
}, { config, db });
|
|
32
|
+
if (result.isError) {
|
|
33
|
+
const errorText = result.content[0]?.text || 'Unknown error';
|
|
34
|
+
return { error: errorText };
|
|
35
|
+
}
|
|
36
|
+
const text = result.content[0].text;
|
|
37
|
+
// Handle "no results" message
|
|
38
|
+
if (text.includes('No results found')) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const data = JSON.parse(text);
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return {
|
|
46
|
+
error: error instanceof Error ? error.message : String(error),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
db.close();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Format search result for CLI display.
|
|
55
|
+
*/
|
|
56
|
+
function formatResult(result, index) {
|
|
57
|
+
const lines = [];
|
|
58
|
+
const title = result.title || result.t;
|
|
59
|
+
const path = result.path || result.p;
|
|
60
|
+
const excerpt = result.excerpt || result.ex;
|
|
61
|
+
const matchCount = result.matchCount ?? result.mc;
|
|
62
|
+
const lineNumber = result.lineNumber ?? result.ln;
|
|
63
|
+
lines.push(`${index + 1}. ${title}`);
|
|
64
|
+
lines.push(` Path: ${path}`);
|
|
65
|
+
lines.push(` Matches: ${matchCount} | Line: ${lineNumber}`);
|
|
66
|
+
lines.push(` ${excerpt}`);
|
|
67
|
+
return lines;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Search documents using full-text search.
|
|
71
|
+
*
|
|
72
|
+
* @param config - Server configuration
|
|
73
|
+
* @param options - Search options
|
|
74
|
+
* @returns Formatted string output for CLI
|
|
75
|
+
*/
|
|
76
|
+
export async function searchDocs(config, options) {
|
|
77
|
+
const result = await getSearchDocsData(config, options);
|
|
78
|
+
if ('error' in result) {
|
|
79
|
+
return `Error: ${result.error}`;
|
|
80
|
+
}
|
|
81
|
+
const lines = [];
|
|
82
|
+
lines.push(`Search results for: "${options.query}"`);
|
|
83
|
+
lines.push('');
|
|
84
|
+
if (result.length === 0) {
|
|
85
|
+
lines.push('No results found');
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
for (let i = 0; i < result.length; i++) {
|
|
89
|
+
lines.push(...formatResult(result[i], i));
|
|
90
|
+
if (i < result.length - 1) {
|
|
91
|
+
lines.push('');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
lines.push('');
|
|
95
|
+
lines.push(`Total: ${result.length} result(s)`);
|
|
96
|
+
}
|
|
97
|
+
return lines.join('\n');
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=docs-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-search.js","sourceRoot":"","sources":["../../src/cli/docs-search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAY/B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAoB,EACpB,OAA0B;IAE1B,+BAA+B;IAC/B,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAEtC,IAAI,CAAC;QACH,YAAY,CAAC,EAAE,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,MAAM,gBAAgB,CACnC;YACE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE;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,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: update-doc
|
|
3
|
+
* Update existing documents.
|
|
4
|
+
*/
|
|
5
|
+
import type { ServerConfig } from '../config.js';
|
|
6
|
+
import type { UpdateDocOutput } from '../tools/update-doc.js';
|
|
7
|
+
/**
|
|
8
|
+
* Options for updating documents.
|
|
9
|
+
*/
|
|
10
|
+
export interface UpdateDocOptions {
|
|
11
|
+
path: string;
|
|
12
|
+
content?: string;
|
|
13
|
+
mode?: 'overwrite' | 'append' | 'prepend';
|
|
14
|
+
patch?: {
|
|
15
|
+
search: string;
|
|
16
|
+
replace: string;
|
|
17
|
+
};
|
|
18
|
+
createBackup?: boolean;
|
|
19
|
+
force?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get document update result from the tool handler.
|
|
23
|
+
* Returns structured data for rendering.
|
|
24
|
+
*
|
|
25
|
+
* @param config - Server configuration
|
|
26
|
+
* @param options - Update options
|
|
27
|
+
* @returns Update result or error message
|
|
28
|
+
*/
|
|
29
|
+
export declare function getUpdateDocData(config: ServerConfig, options: UpdateDocOptions): Promise<UpdateDocOutput | {
|
|
30
|
+
error: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Update an existing document.
|
|
34
|
+
*
|
|
35
|
+
* @param config - Server configuration
|
|
36
|
+
* @param options - Update options
|
|
37
|
+
* @returns Formatted string output for CLI
|
|
38
|
+
*/
|
|
39
|
+
export declare function updateDoc(config: ServerConfig, options: UpdateDocOptions): Promise<string>;
|
|
40
|
+
//# sourceMappingURL=docs-update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-update.d.ts","sourceRoot":"","sources":["../../src/cli/docs-update.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,wBAAwB,CAAC;AAM9E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC1C,KAAK,CAAC,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAkC9C;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBhG"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: update-doc
|
|
3
|
+
* Update existing documents.
|
|
4
|
+
*/
|
|
5
|
+
import { handleUpdateDoc } from '../tools/update-doc.js';
|
|
6
|
+
import { initializeDatabase, createSchema } from '../indexer.js';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import { mkdirSync } from 'fs';
|
|
9
|
+
/**
|
|
10
|
+
* Get document update result from the tool handler.
|
|
11
|
+
* Returns structured data for rendering.
|
|
12
|
+
*
|
|
13
|
+
* @param config - Server configuration
|
|
14
|
+
* @param options - Update options
|
|
15
|
+
* @returns Update result or error message
|
|
16
|
+
*/
|
|
17
|
+
export async function getUpdateDocData(config, options) {
|
|
18
|
+
// Ensure data directory exists
|
|
19
|
+
mkdirSync(config.dataPath, { recursive: true });
|
|
20
|
+
const dbPath = resolve(config.dataPath, 'documents.sqlite');
|
|
21
|
+
const db = initializeDatabase(dbPath);
|
|
22
|
+
try {
|
|
23
|
+
createSchema(db);
|
|
24
|
+
const input = {
|
|
25
|
+
path: options.path,
|
|
26
|
+
content: options.content,
|
|
27
|
+
mode: options.mode || 'overwrite',
|
|
28
|
+
patch: options.patch ? { ...options.patch, all: false } : undefined,
|
|
29
|
+
createBackup: options.createBackup ?? true,
|
|
30
|
+
force: options.force || false,
|
|
31
|
+
prettyPrint: true,
|
|
32
|
+
};
|
|
33
|
+
const result = await handleUpdateDoc(input, { config, db });
|
|
34
|
+
if (result.isError) {
|
|
35
|
+
const errorText = result.content[0]?.text || 'Unknown error';
|
|
36
|
+
return { error: errorText };
|
|
37
|
+
}
|
|
38
|
+
const data = JSON.parse(result.content[0].text);
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return {
|
|
43
|
+
error: error instanceof Error ? error.message : String(error),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
db.close();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Update an existing document.
|
|
52
|
+
*
|
|
53
|
+
* @param config - Server configuration
|
|
54
|
+
* @param options - Update options
|
|
55
|
+
* @returns Formatted string output for CLI
|
|
56
|
+
*/
|
|
57
|
+
export async function updateDoc(config, options) {
|
|
58
|
+
const result = await getUpdateDocData(config, options);
|
|
59
|
+
if ('error' in result) {
|
|
60
|
+
return `Error: ${result.error}`;
|
|
61
|
+
}
|
|
62
|
+
const lines = [];
|
|
63
|
+
lines.push('✓ Document updated successfully');
|
|
64
|
+
lines.push('');
|
|
65
|
+
lines.push(`Path: ${result.path}`);
|
|
66
|
+
lines.push(`Size: ${(result.size / 1024).toFixed(1)} KB`);
|
|
67
|
+
if (result.backup) {
|
|
68
|
+
lines.push(`Backup: ${result.backup}`);
|
|
69
|
+
}
|
|
70
|
+
if (result.changes) {
|
|
71
|
+
lines.push(`Changes: +${result.changes.additions} -${result.changes.deletions} lines`);
|
|
72
|
+
}
|
|
73
|
+
return lines.join('\n');
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=docs-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs-update.js","sourceRoot":"","sources":["../../src/cli/docs-update.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAiB/B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAoB,EACpB,OAAyB;IAEzB,+BAA+B;IAC/B,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAEtC,IAAI,CAAC;QACH,YAAY,CAAC,EAAE,CAAC,CAAC;QACjB,MAAM,KAAK,GAAmB;YAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,OAAO,CAA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M,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAC9C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACnC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAE1D,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,KAAK,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,OAAO,CAAC,SAAS,KAAK,MAAM,CAAC,OAAO,CAAC,SAAS,QAAQ,CAAC,CAAC;IACzF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/cli/init-project.js
CHANGED
|
@@ -89,7 +89,7 @@ export function initProject(targetPath = '.') {
|
|
|
89
89
|
lines.push('');
|
|
90
90
|
// Daemon management
|
|
91
91
|
lines.push('Manage the daemon:');
|
|
92
|
-
lines.push(` ${localPlannerPath} status
|
|
92
|
+
lines.push(` ${localPlannerPath} server-status --config "${configPath}" # Check status`);
|
|
93
93
|
lines.push(` ${localPlannerPath} stop --config "${configPath}" # Stop daemon`);
|
|
94
94
|
lines.push('');
|
|
95
95
|
// CLI usage
|