@dailephd/my-dev-kit 1.0.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/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +221 -0
- package/dist/cli.js +2611 -0
- package/docs/ARCHITECTURE.md +649 -0
- package/docs/CI_CD.md +248 -0
- package/docs/COMMANDS.md +684 -0
- package/docs/DEVELOPMENT.md +360 -0
- package/docs/GRAPH_SCHEMA.md +675 -0
- package/docs/QUICKSTART.md +243 -0
- package/docs/RELEASE.md +249 -0
- package/docs/ROADMAP.md +733 -0
- package/docs/SECURITY.md +92 -0
- package/docs/WORKFLOWS.md +316 -0
- package/examples/README.md +23 -0
- package/examples/basic-python/README.md +14 -0
- package/examples/basic-python/src/main.py +38 -0
- package/examples/basic-python/src/utils.py +24 -0
- package/examples/basic-ts/README.md +14 -0
- package/examples/basic-ts/src/index.ts +6 -0
- package/examples/basic-ts/src/userService.ts +9 -0
- package/examples/basic-ts/src/userTypes.ts +6 -0
- package/package.json +51 -0
package/docs/SECURITY.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
This document describes the security model, boundaries, and audit findings for my-dev-kit.
|
|
4
|
+
|
|
5
|
+
For command flags, see [COMMANDS.md](COMMANDS.md). For architecture details, see [ARCHITECTURE.md](ARCHITECTURE.md).
|
|
6
|
+
|
|
7
|
+
## Security model
|
|
8
|
+
|
|
9
|
+
my-dev-kit is a local, offline CLI tool. It reads source files and JSON artifact files from the local filesystem and writes output files. It does not:
|
|
10
|
+
|
|
11
|
+
- Make network requests
|
|
12
|
+
- Call external services or LLMs
|
|
13
|
+
- Execute arbitrary code from indexed projects
|
|
14
|
+
- Spawn shells or evaluate dynamic input as code
|
|
15
|
+
|
|
16
|
+
The attack surface is limited to:
|
|
17
|
+
|
|
18
|
+
- Crafted JSON artifact files (`manifest.json`, `code-graph.json`, `symbol-index.json`) that could cause path traversal or trigger unsafe behavior during artifact loading
|
|
19
|
+
- Malicious file paths embedded in artifacts that could read files outside the project root during source retrieval
|
|
20
|
+
- DOT output injection through symbol names, node IDs, or edge labels
|
|
21
|
+
- The Graphviz `dot` subprocess invocation (SVG/PNG rendering only)
|
|
22
|
+
|
|
23
|
+
## Boundaries enforced
|
|
24
|
+
|
|
25
|
+
### Source retrieval path containment
|
|
26
|
+
|
|
27
|
+
`getSourceSlice` enforces that all source file reads stay within `manifest.projectRoot`. The check uses `path.relative` and rejects any path whose relative form starts with `..` or is absolute.
|
|
28
|
+
|
|
29
|
+
Paths that escape the project root are rejected with a clear error before any file I/O occurs.
|
|
30
|
+
|
|
31
|
+
### Artifact path containment
|
|
32
|
+
|
|
33
|
+
`readIndexManifest` resolves artifact paths recorded in `manifest.json` (for `symbolIndex`, `codeGraph`, `callGraph`) relative to the index directory and validates that each resolved path stays within the index directory using `isInsideRoot`. A crafted manifest with paths like `../../../../etc/passwd` is rejected before the artifact file is opened.
|
|
34
|
+
|
|
35
|
+
### DOT output escaping
|
|
36
|
+
|
|
37
|
+
`buildDotGraph` quotes all node IDs, node labels, edge source/target IDs, and edge labels through a single `quote()` function that escapes backslashes (`\` → `\\`), double-quotes (`"` → `\"`), and newlines (CR+LF/LF → `\n`). This prevents DOT syntax injection through symbol names, file paths, or user-provided edge labels in artifact data.
|
|
38
|
+
|
|
39
|
+
### Graphviz subprocess isolation
|
|
40
|
+
|
|
41
|
+
`renderGraphviz` invokes `dot` using `spawnSync` with `shell: false`. The DOT content is passed as stdin, not as a shell argument or temporary file. The format argument is pre-validated to be `'svg'` or `'png'` before the subprocess is launched. There is no shell interpolation.
|
|
42
|
+
|
|
43
|
+
### Python indexing subprocess isolation
|
|
44
|
+
|
|
45
|
+
Python indexing invokes `python` or `python3` with `shell: false` and passes embedded `ast` parsing scripts via `python -c`. Indexed Python source is provided on stdin and parsed statically. my-dev-kit does not import or execute user Python modules during symbol, import, or call-graph extraction.
|
|
46
|
+
|
|
47
|
+
### Traversal limits
|
|
48
|
+
|
|
49
|
+
All graph traversal operations are bounded:
|
|
50
|
+
|
|
51
|
+
- Slice depth: 0 through 3 (`validateSliceInputs`)
|
|
52
|
+
- Lookup depth: 0 through 3 (`validateDepth`)
|
|
53
|
+
- Source line range: capped by `--max-lines` (default 160), enforced in `validateLineRange`
|
|
54
|
+
- Search result limit: 1 through 100 (`parseLimit`)
|
|
55
|
+
|
|
56
|
+
These limits prevent runaway traversal on large or pathologically-shaped graphs.
|
|
57
|
+
|
|
58
|
+
### Output path behavior
|
|
59
|
+
|
|
60
|
+
The `--out` flags in `source`, `view`, and `slice` commands accept user-specified output paths. These paths are resolved to absolute form and parent directories are created automatically. There is no traversal restriction on output destinations — users control where output is written. This is intentional for a local CLI tool.
|
|
61
|
+
|
|
62
|
+
## User responsibilities when indexing private repositories
|
|
63
|
+
|
|
64
|
+
my-dev-kit reads source files and writes index artifacts containing file paths, symbol names, and import data from the indexed project. When indexing a private repository:
|
|
65
|
+
|
|
66
|
+
- Index artifacts (`manifest.json`, `symbol-index.json`, `code-graph.json`) contain structural metadata about the project. Treat them with the same access controls as the source code.
|
|
67
|
+
- The `--out` directory should be placed inside the project root or another location that matches your project's access policy.
|
|
68
|
+
- Do not publish index artifacts or include them in version control unless intentional.
|
|
69
|
+
|
|
70
|
+
## Dependency security
|
|
71
|
+
|
|
72
|
+
The production runtime has no npm dependencies beyond Node.js built-ins and the `commander` package for CLI argument parsing.
|
|
73
|
+
|
|
74
|
+
The `esbuild` package used in the build and test infrastructure has a known moderate-severity advisory (GHSA-67mh-4wv8-2f99) affecting `esbuild ≤ 0.24.2` via `vite` and `vitest`. This affects development tooling only. The built `dist/cli.js` output does not include esbuild or vite at runtime.
|
|
75
|
+
|
|
76
|
+
Run `npm audit` to see the current advisory status. Upgrading `vitest` to v4.x would resolve the esbuild advisory but may introduce breaking changes in the test suite.
|
|
77
|
+
|
|
78
|
+
## Security test coverage
|
|
79
|
+
|
|
80
|
+
Security tests are in `tests/security/`:
|
|
81
|
+
|
|
82
|
+
| File | What it tests |
|
|
83
|
+
| ---- | -------------- |
|
|
84
|
+
| `pathTraversal.spec.ts` | `ensureInsideProjectRoot` and `isInsideRoot` reject `../` traversal patterns |
|
|
85
|
+
| `malformedArtifacts.spec.ts` | `readIndexManifest` rejects missing, invalid, or traversal-exploiting manifests |
|
|
86
|
+
| `dotEscaping.spec.ts` | `buildDotGraph` escapes quotes, backslashes, newlines, and angle brackets |
|
|
87
|
+
| `outputPath.spec.ts` | Write helpers create parent directories and return normalized paths |
|
|
88
|
+
| `graphTraversalLimits.spec.ts` | Slice depth, lookup depth, and source line range limits are enforced |
|
|
89
|
+
|
|
90
|
+
## Reporting
|
|
91
|
+
|
|
92
|
+
This is a local open-source CLI tool with no external services. If you discover a security issue, open an issue in the project repository with a description of the finding and a reproduction case.
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# Workflows
|
|
2
|
+
|
|
3
|
+
Practical usage workflows for my-dev-kit. For the full flag reference, see [COMMANDS.md](COMMANDS.md). For artifact and schema details, see [GRAPH_SCHEMA.md](GRAPH_SCHEMA.md).
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The recommended usage pattern:
|
|
8
|
+
|
|
9
|
+
1. Index the project once, then re-run when source changes.
|
|
10
|
+
2. Use `search` to discover relevant node IDs.
|
|
11
|
+
3. Use `lookup` or `slice` to inspect graph relationships.
|
|
12
|
+
4. Use `source` to retrieve specific code excerpts.
|
|
13
|
+
5. Use `view` to render the full graph when a visual overview is needed.
|
|
14
|
+
|
|
15
|
+
Do not start by reading the full graph or full source tree. Use `search` first to narrow the context.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Workflow 1: Index a TypeScript or JavaScript project
|
|
20
|
+
|
|
21
|
+
Run `index` from the project root:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
my-dev-kit index --root . --src src --out .my-dev-kit --json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The `--out` path is relative to `--root`. The above creates `.my-dev-kit/`.
|
|
28
|
+
|
|
29
|
+
Include a call graph:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
my-dev-kit index --root . --src src --out .my-dev-kit --call-graph --json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Index multiple source roots:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
my-dev-kit index --root . --src src --src tests --out .my-dev-kit --json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For large monorepos, avoid indexing broad roots that contain application output, dependency folders, caches, or generated artifacts. Target the source folders that matter for the current workflow:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
my-dev-kit index --root . --src apps/web/app --src apps/web/lib --src apps/web/prisma --out .my-dev-kit-web --call-graph --json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
my-dev-kit skips common generated, dependency, cache, and build directories by default, including `node_modules`, `.next`, `dist`, `build`, `coverage`, `playwright-report`, `test-results`, `output`, `out`, `.cache`, `.turbo`, `.vercel`, `.git`, `.pytest_cache`, `__pycache__`, `.venv`, and `venv`. Add project-specific exclusions with repeated `--exclude` values:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
my-dev-kit index --root . --src apps/web --out .my-dev-kit-web --exclude .next --exclude coverage --exclude apps/web/generated --json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Use `--dry-run` before indexing a large tree, and add `--progress` when you want phase and count diagnostics. Progress is written to stderr and does not corrupt JSON stdout.
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
my-dev-kit index --root . --src apps/web --out .my-dev-kit-web --dry-run --json
|
|
57
|
+
my-dev-kit index --root . --src apps/web/app --src apps/web/lib --out .my-dev-kit-web --progress --json
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Split indexes can keep focused workflows faster and easier to inspect:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
my-dev-kit index --root . --src apps/web/app --src apps/web/lib --src apps/web/prisma --out .my-dev-kit-web --call-graph --json
|
|
64
|
+
my-dev-kit index --root . --src apps/web/tests --src apps/web/e2e --out .my-dev-kit-web-tests --exclude playwright-report --exclude test-results --json
|
|
65
|
+
my-dev-kit index --root . --src apps/nlp-service/src --language python --out .my-dev-kit-nlp --call-graph --json
|
|
66
|
+
my-dev-kit index --root . --src scripts --out .my-dev-kit-scripts --json
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Workflow 2: Index a Python project
|
|
72
|
+
|
|
73
|
+
Python indexing requires `python` or `python3` on `PATH` with Python 3.8 or later. The `--language python` flag selects Python mode. Language can also be inferred from `.py` file extensions.
|
|
74
|
+
|
|
75
|
+
**Step 1: Index the Python source root**
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
my-dev-kit index --root . --src src --language python --out .my-dev-kit --json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Include a static call graph when call edges are useful:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
my-dev-kit index --root . --src src --language python --out .my-dev-kit --call-graph --json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Step 2: Search for Python symbols**
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
my-dev-kit search --index .my-dev-kit --query "greet" --limit 20 --json
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Step 3: Look up a Python node**
|
|
94
|
+
|
|
95
|
+
```sh
|
|
96
|
+
my-dev-kit lookup --index .my-dev-kit --node file:src/main.py --depth 1 --json
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Step 4: Retrieve Python source**
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
my-dev-kit source --index .my-dev-kit --file src/main.py --symbol greet --format numbered
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Use line-range retrieval for exact bounds:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
my-dev-kit source --index .my-dev-kit --file src/main.py --start 1 --end 40 --format numbered
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Python notes:**
|
|
112
|
+
|
|
113
|
+
- Call-graph extraction is static and conservative. It uses `ast` parsing and may miss dynamic calls.
|
|
114
|
+
- If no Python interpreter is found on `PATH`, Python files are skipped with a warning in the manifest.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Workflow 3: Graph-Guided Symbol Retrieval
|
|
119
|
+
|
|
120
|
+
Graph-Guided Symbol Retrieval is the recommended approach when navigating an unfamiliar codebase. It avoids broad file reading by narrowing context progressively from keyword search to exact graph nodes to targeted source excerpts.
|
|
121
|
+
|
|
122
|
+
**Step 1: Index the project**
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
my-dev-kit index --root . --src src --out .my-dev-kit --json
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Step 2: Search to narrow candidates**
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
my-dev-kit search --index .my-dev-kit --query "<relevant term>" --limit 20 --json
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Inspect `nodeId`, `kind`, and `matchReasons` in the results. Prefer symbol nodes when the target is a specific function, class, or type.
|
|
135
|
+
|
|
136
|
+
**Step 3: Look up the strongest candidate**
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
my-dev-kit lookup --index .my-dev-kit --node "<node-id>" --depth 1 --json
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Review incoming edges, outgoing edges, and neighbors to understand the node's relationships. Repeat for adjacent nodes as needed.
|
|
143
|
+
|
|
144
|
+
**Step 4: Slice around the focus node**
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
my-dev-kit slice --index .my-dev-kit --node "<node-id>" --depth 2 --direction both --json
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The slice provides a bounded subgraph view that is easier to reason about than the full graph.
|
|
151
|
+
|
|
152
|
+
**Step 5: Retrieve source for specific symbols**
|
|
153
|
+
|
|
154
|
+
Use symbol-mode retrieval when possible:
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
my-dev-kit source --index .my-dev-kit --file "<path>" --symbol "<symbol-name>" --format numbered
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Use line-range retrieval when symbol-mode is too broad or incomplete:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
my-dev-kit source --index .my-dev-kit --file "<path>" --start <n> --end <n> --format numbered
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**What to avoid:**
|
|
167
|
+
|
|
168
|
+
- Do not read full `code-graph.json` manually to find node IDs. Use `search` first.
|
|
169
|
+
- Do not retrieve large line ranges when a symbol name is known. Use `--symbol` mode first.
|
|
170
|
+
- Do not iterate all files before searching. Let `search` narrow the scope.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Workflow 4: Generate graph visualization
|
|
175
|
+
|
|
176
|
+
DOT output does not require Graphviz:
|
|
177
|
+
|
|
178
|
+
```sh
|
|
179
|
+
my-dev-kit view --index .my-dev-kit --format dot --out .my-dev-kit/graph.dot
|
|
180
|
+
my-dev-kit view --index .my-dev-kit --format dot --edge-style labeled --out .my-dev-kit/graph.labeled.dot
|
|
181
|
+
my-dev-kit view --index .my-dev-kit --format dot --edge-style minimal --out .my-dev-kit/graph.minimal.dot
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
SVG output requires Graphviz:
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
my-dev-kit view --index .my-dev-kit --format svg --out .my-dev-kit/graph.svg
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Fall back to DOT if Graphviz is unavailable:
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
my-dev-kit view --index .my-dev-kit --format svg --allow-dot-fallback --out .my-dev-kit/graph.dot
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Use `--format dot` for automated checks. Reserve SVG or PNG for interactive review.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Workflow 5: Use my-dev-kit with ChatGPT or a coding agent
|
|
201
|
+
|
|
202
|
+
LLMs perform better when given bounded, relevant context instead of whole files or broad project dumps. my-dev-kit helps collect that context deterministically from your local project.
|
|
203
|
+
|
|
204
|
+
my-dev-kit does not call LLMs, does not edit files, and does not act as an autonomous agent. It prepares local bounded context for you or for downstream tools.
|
|
205
|
+
|
|
206
|
+
**Command sequence**
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
my-dev-kit index --root . --src src --out .my-dev-kit --json
|
|
210
|
+
my-dev-kit search --index .my-dev-kit --query "<topic>" --limit 20 --json
|
|
211
|
+
my-dev-kit lookup --index .my-dev-kit --node "<node-id>" --depth 1 --json
|
|
212
|
+
my-dev-kit slice --index .my-dev-kit --node "<node-id>" --depth 2 --direction both --json
|
|
213
|
+
my-dev-kit source --index .my-dev-kit --file "<path>" --symbol "<symbol-name>" --format numbered
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**What to paste into the LLM**
|
|
217
|
+
|
|
218
|
+
- Selected search output or a concise summary of the strongest matches
|
|
219
|
+
- Selected lookup output
|
|
220
|
+
- Selected graph slice or a concise summary of nearby nodes and edges
|
|
221
|
+
- Numbered source excerpts
|
|
222
|
+
- File paths, symbol names, and node IDs used to retrieve the context
|
|
223
|
+
|
|
224
|
+
**What not to paste**
|
|
225
|
+
|
|
226
|
+
- The entire source tree
|
|
227
|
+
- Full `symbol-index.json`
|
|
228
|
+
- Full `code-graph.json`
|
|
229
|
+
- Broad unrelated files
|
|
230
|
+
- Generated artifacts that are not relevant to the current task
|
|
231
|
+
|
|
232
|
+
**Reusable prompt template**
|
|
233
|
+
|
|
234
|
+
```text
|
|
235
|
+
I am using my-dev-kit to provide bounded codebase context.
|
|
236
|
+
|
|
237
|
+
Task:
|
|
238
|
+
<describe the coding, debugging, documentation, or refactoring task>
|
|
239
|
+
|
|
240
|
+
Repository context:
|
|
241
|
+
Project root: <project root>
|
|
242
|
+
Index directory: .my-dev-kit
|
|
243
|
+
Source roots indexed: <source roots>
|
|
244
|
+
|
|
245
|
+
Graph-guided retrieval:
|
|
246
|
+
Search query used:
|
|
247
|
+
<query>
|
|
248
|
+
|
|
249
|
+
Search results:
|
|
250
|
+
<paste selected search JSON or summarized result>
|
|
251
|
+
|
|
252
|
+
Selected node:
|
|
253
|
+
<node-id>
|
|
254
|
+
Reason selected:
|
|
255
|
+
<why this node is the strongest candidate>
|
|
256
|
+
|
|
257
|
+
Lookup result:
|
|
258
|
+
<paste lookup result or concise summary>
|
|
259
|
+
|
|
260
|
+
Graph slice:
|
|
261
|
+
<paste slice result or concise summary>
|
|
262
|
+
|
|
263
|
+
Source excerpts:
|
|
264
|
+
<paste numbered source output with file paths>
|
|
265
|
+
|
|
266
|
+
Instructions:
|
|
267
|
+
Use only the provided context unless you explicitly say what additional file, symbol, or graph node is needed.
|
|
268
|
+
Do not assume unrelated files were inspected.
|
|
269
|
+
If the context is insufficient, ask for the next my-dev-kit search, lookup, slice, or source command to run.
|
|
270
|
+
Prefer targeted changes grounded in the retrieved source.
|
|
271
|
+
Explain which provided evidence supports your answer.
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**When to rerun commands**
|
|
275
|
+
|
|
276
|
+
- Re-run `index` after source changes so graph artifacts match the current project.
|
|
277
|
+
- Use better query terms if `search` results are weak. Try symbol names, feature terms, error text, file names, or imported module names.
|
|
278
|
+
- Use `lookup --depth 1` first. Increase depth only when the immediate graph neighborhood is insufficient.
|
|
279
|
+
- Use `slice --depth 1` or `slice --depth 2` depending on context size.
|
|
280
|
+
- Use line-range source retrieval when symbol retrieval is too broad or incomplete.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Bundled examples
|
|
285
|
+
|
|
286
|
+
The examples are for cloned repositories, documentation writers, and package smoke tests. Normal npm users should run my-dev-kit inside their own project.
|
|
287
|
+
|
|
288
|
+
```sh
|
|
289
|
+
my-dev-kit index --root examples/basic-ts --src src --out .my-dev-kit --json
|
|
290
|
+
my-dev-kit search --index examples/basic-ts/.my-dev-kit --query "service" --limit 5 --json
|
|
291
|
+
|
|
292
|
+
my-dev-kit index --root examples/basic-python --src src --language python --out .my-dev-kit --json
|
|
293
|
+
my-dev-kit search --index examples/basic-python/.my-dev-kit --query "greet" --limit 5 --json
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Troubleshooting
|
|
299
|
+
|
|
300
|
+
**Problem: "Missing index manifest"**
|
|
301
|
+
The index artifact directory does not contain `manifest.json`. Run `index` first, or check the `--index` path.
|
|
302
|
+
|
|
303
|
+
**Problem: "Unknown node ID"**
|
|
304
|
+
The node ID passed to `lookup`, `source`, or `slice` is not in the graph. Use `search` to discover valid node IDs.
|
|
305
|
+
|
|
306
|
+
**Problem: "Symbol not found"**
|
|
307
|
+
The symbol name does not match any indexed symbol in the specified file. Run `search --query <symbol-name>` to confirm spelling and which file contains it.
|
|
308
|
+
|
|
309
|
+
**Problem: "Graphviz dot executable is not available"**
|
|
310
|
+
SVG and PNG rendering requires Graphviz. Install Graphviz, use `--format dot`, or add `--allow-dot-fallback`.
|
|
311
|
+
|
|
312
|
+
**Problem: Result content is capped with a preview warning**
|
|
313
|
+
Symbol retrieval is bounded from the start line. Increase `--max-lines` or use line-range mode with explicit `--start` and `--end` values.
|
|
314
|
+
|
|
315
|
+
**Problem: Python symbols not indexed or warnings about Python interpreter**
|
|
316
|
+
Python indexing requires `python` or `python3` on `PATH`. Install Python 3.8 or later and ensure the interpreter is accessible.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
These folders are small projects for learning and smoke testing my-dev-kit from a cloned repository or inspected package contents.
|
|
4
|
+
|
|
5
|
+
- `basic-ts` is a small TypeScript project for learning command behavior and running smoke checks.
|
|
6
|
+
- `basic-python` is a small Python project for learning command behavior and running smoke checks.
|
|
7
|
+
|
|
8
|
+
Normal npm users should run `my-dev-kit` inside their own project:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
cd <your-project>
|
|
12
|
+
my-dev-kit index --root . --src src --out .my-dev-kit --json
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Use these examples when you want a tiny known project:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
my-dev-kit index --root examples/basic-ts --src src --out .my-dev-kit --json
|
|
19
|
+
my-dev-kit search --index examples/basic-ts/.my-dev-kit --query "service" --limit 5 --json
|
|
20
|
+
|
|
21
|
+
my-dev-kit index --root examples/basic-python --src src --language python --out .my-dev-kit --json
|
|
22
|
+
my-dev-kit search --index examples/basic-python/.my-dev-kit --query "greet" --limit 5 --json
|
|
23
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# basic-python
|
|
2
|
+
|
|
3
|
+
Small Python project for learning and smoke testing my-dev-kit. Python indexing requires `python` or `python3` on `PATH` with Python 3.8 or later.
|
|
4
|
+
|
|
5
|
+
From the repository root:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
my-dev-kit index --root examples/basic-python --src src --language python --out .my-dev-kit --call-graph --json
|
|
9
|
+
my-dev-kit search --index examples/basic-python/.my-dev-kit --query "greet" --limit 5 --json
|
|
10
|
+
my-dev-kit lookup --index examples/basic-python/.my-dev-kit --node file:src/main.py --depth 1 --json
|
|
11
|
+
my-dev-kit source --index examples/basic-python/.my-dev-kit --file src/main.py --symbol greet --format numbered
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This example is secondary documentation for cloned repositories and package smoke tests. Normal npm users should run `my-dev-kit` inside their own project.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Main module for the basic-python example."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from utils import format_name, Formatter
|
|
5
|
+
|
|
6
|
+
__all__ = ["greet", "UserService"]
|
|
7
|
+
|
|
8
|
+
APP_NAME = "BasicPython"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def greet(name: str) -> str:
|
|
12
|
+
"""Return a greeting string for the given name."""
|
|
13
|
+
return f"Hello, {name}!"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
async def fetch_user(user_id: int) -> dict:
|
|
17
|
+
"""Async function to fetch a user by ID (stub)."""
|
|
18
|
+
return {"id": user_id, "name": "Alice"}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _build_message(template: str, **kwargs) -> str:
|
|
22
|
+
"""Private builder — not in __all__."""
|
|
23
|
+
return template.format(**kwargs)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class UserService:
|
|
27
|
+
"""Service for managing users."""
|
|
28
|
+
|
|
29
|
+
def __init__(self, base_url: str) -> None:
|
|
30
|
+
self.base_url = base_url
|
|
31
|
+
self._formatter = Formatter(prefix="[user] ")
|
|
32
|
+
|
|
33
|
+
def describe(self, first: str, last: str) -> str:
|
|
34
|
+
full = format_name(first, last)
|
|
35
|
+
return self._formatter.format(full)
|
|
36
|
+
|
|
37
|
+
def get_env(self) -> str:
|
|
38
|
+
return os.environ.get("APP_ENV", "development")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Shared utilities for the basic-python example."""
|
|
2
|
+
|
|
3
|
+
MAX_RETRIES = 3
|
|
4
|
+
DEFAULT_TIMEOUT = 30
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def format_name(first: str, last: str) -> str:
|
|
8
|
+
"""Return a formatted full name."""
|
|
9
|
+
return f"{first} {last}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _internal_helper(value: str) -> str:
|
|
13
|
+
"""Private helper not included in public API."""
|
|
14
|
+
return value.strip().lower()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Formatter:
|
|
18
|
+
"""Formats values for display."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, prefix: str = "") -> None:
|
|
21
|
+
self.prefix = prefix
|
|
22
|
+
|
|
23
|
+
def format(self, value: str) -> str:
|
|
24
|
+
return f"{self.prefix}{value}" if self.prefix else value
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# basic-ts
|
|
2
|
+
|
|
3
|
+
Small TypeScript project for learning and smoke testing my-dev-kit.
|
|
4
|
+
|
|
5
|
+
From the repository root:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
my-dev-kit index --root examples/basic-ts --src src --out .my-dev-kit --call-graph --json
|
|
9
|
+
my-dev-kit search --index examples/basic-ts/.my-dev-kit --query "user" --limit 5 --json
|
|
10
|
+
my-dev-kit lookup --index examples/basic-ts/.my-dev-kit --node symbol:src/index.ts#describeUser --depth 1 --json
|
|
11
|
+
my-dev-kit source --index examples/basic-ts/.my-dev-kit --file src/index.ts --symbol describeUser --format numbered
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
This example is secondary documentation for cloned repositories and package smoke tests. Normal npm users should run `my-dev-kit` inside their own project.
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dailephd/my-dev-kit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Local codebase graph, indexing, slicing, source retrieval, search, and Graphviz visualization CLI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"my-dev-kit": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE",
|
|
13
|
+
"CHANGELOG.md",
|
|
14
|
+
"docs/ARCHITECTURE.md",
|
|
15
|
+
"docs/CI_CD.md",
|
|
16
|
+
"docs/COMMANDS.md",
|
|
17
|
+
"docs/DEVELOPMENT.md",
|
|
18
|
+
"docs/GRAPH_SCHEMA.md",
|
|
19
|
+
"docs/QUICKSTART.md",
|
|
20
|
+
"docs/RELEASE.md",
|
|
21
|
+
"docs/ROADMAP.md",
|
|
22
|
+
"docs/SECURITY.md",
|
|
23
|
+
"docs/WORKFLOWS.md",
|
|
24
|
+
"examples/README.md",
|
|
25
|
+
"examples/basic-ts/src",
|
|
26
|
+
"examples/basic-ts/README.md",
|
|
27
|
+
"examples/basic-python/src",
|
|
28
|
+
"examples/basic-python/README.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"dev": "tsx src/cli.ts",
|
|
32
|
+
"build": "tsup",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"verify": "npm run typecheck && npm run test && npm run build",
|
|
36
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
37
|
+
"prepack": "npm run build"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"author": "dailephd LLC",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"commander": "^12.1.0",
|
|
43
|
+
"typescript": "^5.9.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^20.19.25",
|
|
47
|
+
"tsup": "^8.5.1",
|
|
48
|
+
"tsx": "^4.20.6",
|
|
49
|
+
"vitest": "^2.1.9"
|
|
50
|
+
}
|
|
51
|
+
}
|