@facetlayer/docs-tool 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 ADDED
@@ -0,0 +1,80 @@
1
+ # @facetlayer/doc-files-helper
2
+
3
+ Helper library for CLI tools to share their doc files.
4
+
5
+ When an app uses this library, they'll typically have these commands:
6
+
7
+ `<app> list-docs` - List all the doc files with descriptions.
8
+ `<app> get-doc <name>` - Get the contents for a single doc file.
9
+
10
+ The `list-docs` and `get-doc` commands will browse through all the doc files that the
11
+ tool owns. These are typically stored in ./docs.
12
+
13
+ Each doc file should be Markdown and implement frontmatter with `name` and `description`
14
+ (same format that Claude Agent Skills uses). The name & description are shared when
15
+ doing `list-docs`.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pnpm add @facetlayer/doc-files-helper
21
+ ```
22
+
23
+ ## Example
24
+
25
+ ### Listing Docs
26
+
27
+ ```typescript
28
+ import { DocFilesHelper } from '@facetlayer/doc-files-helper';
29
+
30
+ const helper = new DocFilesHelper({ dirs: ['./docs'] });
31
+ const docs = helper.listDocs();
32
+ // Returns: [{ name: 'my-doc', description: '...', filename: 'my-doc.md' }, ...]
33
+ ```
34
+
35
+ ### Getting a Doc
36
+
37
+ ```typescript
38
+ import { DocFilesHelper } from '@facetlayer/doc-files-helper';
39
+
40
+ const helper = new DocFilesHelper({ dirs: ['./docs'] });
41
+ const doc = helper.getDoc('my-doc');
42
+ // Returns: { name, description, filename, content, rawContent, fullPath }
43
+ ```
44
+
45
+ ## Frontmatter Format
46
+
47
+ Doc files should have YAML frontmatter at the start:
48
+
49
+ ```markdown
50
+ ---
51
+ name: doc-name
52
+ description: Brief description of the doc
53
+ ---
54
+
55
+ # Doc Content
56
+
57
+ Your markdown content here.
58
+ ```
59
+
60
+ ## API
61
+
62
+ ### `DocFilesHelper`
63
+
64
+ Helper class for working with doc files.
65
+
66
+ #### Constructor Options
67
+
68
+ ```typescript
69
+ interface DocFilesHelperOptions {
70
+ dirs?: string[]; // List of directories to search for .md files
71
+ files?: string[]; // List of specific files to include
72
+ }
73
+ ```
74
+
75
+ #### Methods
76
+
77
+ - `listDocs(): DocInfo[]` - Lists all `.md` files with their frontmatter metadata.
78
+ - `getDoc(name: string): DocContent` - Gets a specific doc file by name (without `.md` extension). Throws if not found.
79
+ - `printDocFileList(): void` - Prints a formatted list of all doc files to stdout.
80
+ - `printDocFileContents(name: string): void` - Prints the raw contents of a specific doc file to stdout.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cli.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/cli.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { DocFilesHelper } from './index.ts';
2
+ export interface LocalLibraryDocs {
3
+ libraryPath: string;
4
+ helper: DocFilesHelper;
5
+ hasDocsFolder: boolean;
6
+ }
7
+ /**
8
+ * Create a DocFilesHelper for browsing docs in a local directory.
9
+ * Looks for .md files in the target directory and also in a ./docs subdirectory if it exists.
10
+ */
11
+ export declare function browseLocalLibrary(targetPath: string): LocalLibraryDocs;
12
+ //# sourceMappingURL=browseLocalLibrary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browseLocalLibrary.d.ts","sourceRoot":"","sources":["../src/browseLocalLibrary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAoBvE"}
@@ -0,0 +1,39 @@
1
+ import { DocFilesHelper } from './index.ts';
2
+ export interface LibraryLocation {
3
+ libraryPath: string;
4
+ libraryName: string;
5
+ matchType: 'exact' | 'partial';
6
+ }
7
+ export interface NpmLibraryDocs {
8
+ libraryName: string;
9
+ libraryPath: string;
10
+ helper: DocFilesHelper;
11
+ hasReadme: boolean;
12
+ hasDocsFolder: boolean;
13
+ }
14
+ /**
15
+ * Find a library by name in node_modules directories.
16
+ */
17
+ export declare function findLibraryInNodeModules(libraryName: string, startDir?: string): LibraryLocation | null;
18
+ /**
19
+ * Get the installation directory for libraries that aren't found in node_modules
20
+ */
21
+ export declare function getInstallationDirectory(): string;
22
+ /**
23
+ * Find a library, installing it if necessary
24
+ */
25
+ export declare function findLibrary(libraryName: string, options?: {
26
+ skipInstall?: boolean;
27
+ }): Promise<LibraryLocation | null>;
28
+ /**
29
+ * Create a DocFilesHelper for a library's documentation
30
+ */
31
+ export declare function getLibraryDocs(libraryPath: string, libraryName: string): NpmLibraryDocs;
32
+ /**
33
+ * Browse an NPM library's documentation.
34
+ * First checks local node_modules, then installs from npm if not found.
35
+ */
36
+ export declare function browseNpmLibrary(libraryName: string, options?: {
37
+ skipInstall?: boolean;
38
+ }): Promise<NpmLibraryDocs | null>;
39
+ //# sourceMappingURL=browseNpmLibrary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browseNpmLibrary.d.ts","sourceRoot":"","sources":["../src/browseNpmLibrary.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;CACxB;AAuGD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAiCvG;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CASjD;AA6GD;;GAEG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAiC3H;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,CA+BvF;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAQ/H"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}