MCPcopy Index your code
hub / github.com/JamieMason/self-help

github.com/JamieMason/self-help @0.3.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.3.4 ↗ · + Follow
49 symbols 133 edges 16 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

self-help

Interactive Q&A Guides for Web and the Command Line.

Create decision trees that users and LLMs can navigate to find answers.

Installation

npm install --global self-help

Commands

interactive

Navigate a Self-Help Document from the Command Line interactively.

Examples

# Run an interactive Q&A session
self-help interactive --source ./path/to/help-document.js

screenshot

markdown

Generate Markdown from a Self-Help Document. Markdown is written to stdout for you to pipe into other Command Line Programs or write to a file.

Examples

# Generate markdown documentation
self-help markdown --source ./path/to/help-document.js
# Write output to a file
self-help markdown --source ./path/to/help-document.js > output.md

See the RxJS Operator Decision Tree for an example of exported Markdown.

Writing Documents

A Help Document is a JavaScript Module exporting a getHelpDocument method of type GetHelpDocument.

type GetHelpDocument = () => Node | Promise<Node>;

It returns a Nested Hierarchy of Node Objects which form the Decision Tree a User will navigate.

type Node = Leaf | Branch | AsyncBranch;

Example

export const getHelpDocument = () => ({
  label: 'Welcome to Milk and Cookies, how can we help?',
  children: [
    {
      label: `I'm Thirsty, and`,
      children: () => http.get('/milks-walkthrough.json'),
    },
    {
      label: `I'm Hungry, and`,
      children: [
        {
          label: 'I love Cookies, so',
          children: () => http.get('/cookies-walkthrough.json'),
        },
        {
          label: `Cookies aren't my thing`,
          value: fs.readFileSync('/GET-OUT.md', 'utf8'),
        },
      ],
    },
  ],
});

Node Types

Branch

A Branch presents multiple options to choose from in the form of its children Array. Children can be a combination of other Branch, AsyncBranch or Leaf Nodes.

{
  label: 'I just cloned the project, and',
  children: [...]
}

AsyncBranch

An AsyncBranch is the same as a Branch except its children property is a Function which returns a Promise.

This mechanism allows Help Documents to be combined and linked together. Use it to compose higher-level guides which pull together other Help Documents hosted online or break down a large Help Document into smaller files that can be lazily-loaded at runtime.

{
  label: 'I just cloned the project, and',
  children: () => Promise.resolve([])
}

Leaf

A Leaf represents the answer the User has been looking for as they have been navigating a given Help Document. The value can be any String, but is normally the contents of a Markdown Document which explains the answer to the User.

{
  label: 'I want to install dependencies',
  value: fs.readFileSync('/installation.md', 'utf8')
}

Badges

  • NPM version
  • NPM downloads

Extension points exported contracts — how you extend this code

Leaf (Interface)
(no doc)
src/index.ts
HelpDocumentSource (Interface)
(no doc)
src/markdown.ts
HelpDocumentSource (Interface)
(no doc)
src/interactive.ts
JsonReadOptions (Interface)
(no doc)
src/lib/json.ts
TreeContext (Interface)
(no doc)
src/machine/tree/index.ts
Branch (Interface)
(no doc)
src/index.ts
FinaliseEvent (Interface)
(no doc)
src/machine/tree/index.ts
AsyncBranch (Interface)
(no doc)
src/index.ts

Core symbols most depended-on inside this repo

createTreeInterpreter
called by 11
src/machine/tree/index.ts
isLeaf
called by 10
src/machine/tree/nodes.ts
isBranch
called by 10
src/machine/tree/nodes.ts
isChildren
called by 8
src/machine/tree/nodes.ts
isAsyncBranch
called by 8
src/machine/tree/nodes.ts
isNode
called by 8
src/machine/tree/nodes.ts
isString
called by 6
src/lib/utils.ts
createTreeMachine
called by 6
src/machine/tree/index.ts

Shape

Function 37
Interface 12

Languages

TypeScript100%

Modules by API surface

src/machine/tree/index.ts9 symbols
src/interactive.ts9 symbols
src/machine/tree/nodes.ts8 symbols
src/lib/markdown.ts7 symbols
src/lib/utils.ts4 symbols
src/index.ts3 symbols
src/markdown.ts2 symbols
src/machine/tree/index.spec.ts2 symbols
src/lib/try-panic.ts2 symbols
src/lib/json.ts2 symbols
src/fixtures/rxjs-operator-decision-tree.ts1 symbols

For agents

$ claude mcp add self-help \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact