cto-ai 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Siddhant Bali
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,137 @@
1
- # Temporary Holding Version
1
+ # ctoai
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The persistent project brain for any coding agent — file-first, graph-powered, MCP-native.
4
+
5
+ > **Status: `0.1.0` — Phase 1 complete.** Every command is implemented against the file-system store: scan, incremental index, the tool catalogue, append-only memory, the spec workflow, guards, and an MCP server. FalkorDB is the Phase 2 adapter behind the same interface. See the [roadmap](https://github.com/kintsugi-programmer/cto-ai/blob/main/Documents/project-notes/2026-10-18-cto-ai-implementation-roadmap.md).
6
+
7
+ ## Install
8
+
9
+ The npm package is **`cto-ai`**; the command it installs is **`ctoai`**.
10
+
11
+ ```bash
12
+ npx cto-ai --help # run without installing
13
+ npm install -g cto-ai # or install the `ctoai` command
14
+ ```
15
+
16
+ Both `ctoai` and `cto-ai` work as commands once installed.
17
+
18
+ ## Quick start
19
+
20
+ ```bash
21
+ ctoai init # scaffold .cto-ai/ and adopt any existing context
22
+ ctoai sync # build the index (incremental, deterministic)
23
+ ctoai resume # what is going on here, in one call
24
+ ctoai status # coverage and health
25
+ ```
26
+
27
+ `ctoai init` is idempotent: re-running it changes nothing and never duplicates the managed block in `AGENTS.md`.
28
+
29
+ ## Commands
30
+
31
+ | Command | What it does |
32
+ |---|---|
33
+ | `init [--force]` | Scan the repo, scaffold `.cto-ai/`, import existing context, add the managed block to entry files. |
34
+ | `sync [--full] [--no-git]` | Rebuild the index incrementally from content hashes. Byte-identical when nothing changed. |
35
+ | `status` | Node/edge/type counts, coverage, staleness, open items, last sync time. |
36
+ | `resume [-n <limit>]` | Next up, active spec unit, recent decisions and findings, open questions. |
37
+ | `query <tool> [args]` | Run one catalogue tool. `--path --from --to --task --about --depth --limit`. |
38
+ | `record [kind]` | `session \| finding \| decision`, with `--text --body --about`. `--close` ends the open session. |
39
+ | `export --format <f> [--out dir]` | `six-file`, `handoff`, or `json`. |
40
+ | `import <source>` | Adopt a six-file folder or a planning transcript. |
41
+ | `guards <path>` | The rules and invariants that apply to a path, plus other protected files you have modified. |
42
+ | `check [--ci]` | Drift detection: modified files that trip a guard rule. Exits non-zero under `--ci`. |
43
+ | `spec [list\|next\|close] [unit]` | Build-plan workflow. `close` runs the unit's verify commands. |
44
+ | `connect [--url] [--backfill]` | Validate a FalkorDB endpoint, store non-secret settings, optionally push the index. |
45
+ | `mcp` | Run the MCP server over stdio. |
46
+
47
+ Every command accepts `--json` for a stable machine-readable schema, and `-C <dir>` to pick a project without `cd`-ing.
48
+
49
+ ## Tools
50
+
51
+ Agents call tools; they never compose queries. Each tool validates its arguments, resolves them against the graph, and returns the path it walked plus an honest outcome: `answered`, `from-memory`, `not-indexed`, or `unknown`.
52
+
53
+ | Tool | Args | Answers |
54
+ |---|---|---|
55
+ | `blast_radius` | `path`, `depth<=4` | Everything that depends on a file or directory. |
56
+ | `why_connected` | `from`, `to`, `depth` | Shortest path between two artifacts, with every edge. |
57
+ | `load_bearing` | `limit<=20` | Most depended-upon files, by dependency PageRank. |
58
+ | `context_for` | `task`, `limit` | The relevant subgraph for a task (lexical seed + bounded traversal). |
59
+ | `recall` | `about`, `limit` | Findings, sessions, and decisions about something, newest first. |
60
+ | `timeline` | `path`, `limit` | Change and decision history for one artifact. |
61
+ | `islands` | `limit` | Disconnected clusters. |
62
+ | `communities` | `limit` | Module clusters by label propagation. |
63
+ | `guards` | `path` | Rules that apply to a path. |
64
+ | `status` | – | Coverage, health, and counts. |
65
+
66
+ ## MCP
67
+
68
+ ```bash
69
+ ctoai mcp
70
+ ```
71
+
72
+ Registers the ten tools above plus `record`, so an agent can read context and write memory. Point your client at the command:
73
+
74
+ ```json
75
+ {
76
+ "mcpServers": {
77
+ "ctoai": { "command": "npx", "args": ["-y", "cto-ai", "mcp"] }
78
+ }
79
+ }
80
+ ```
81
+
82
+ Before starting work, call `resume`. Before changing a protected path, call `guards`. When a decision is made, call `record`.
83
+
84
+ ## Storage model
85
+
86
+ Three layers, one source of truth per artifact class. There is no bidirectional sync.
87
+
88
+ - **`context/`, `specs/`, `notes/`, `skills/`** — human-authored markdown. You own these.
89
+ - **`log/`** — append-only agent memory. One JSON file per session, finding, or decision; never rewritten, so no merge conflicts and full temporal history. The agent owns this.
90
+ - **`index/`** — derived, gitignored, disposable. `nodes.jsonl`, `edges.jsonl`, `hashes.json`, `health.json`. Rebuild it with `ctoai sync`.
91
+
92
+ Graph v0: 15 node types (`Project`, `Dir`, `File`, `Note`, `Meeting`, `Decision`, `Finding`, `Session`, `Episode`, `Requirement`, `Feature`, `Skill`, `Spec`, `Task`, `Person`) and 11 edge types (`CONTAINS`, `DEPENDS_ON`, `LINKS_TO`, `MENTIONS`, `ABOUT`, `DECIDED_IN`, `LEARNED_IN`, `PART_OF`, `SUPERSEDES`, `IMPLEMENTS`, `TOUCHED`).
93
+
94
+ Decisions are superseded, never deleted. A later decision about the same target gets a `SUPERSEDES` edge to the earlier one, so `recall` can show history instead of the latest value alone.
95
+
96
+ ## FalkorDB
97
+
98
+ File mode is the honest default: no account, no server, works offline. `ctoai connect` upgrades to the graph.
99
+
100
+ ```bash
101
+ export FALKORDB_URL=redis://localhost:6379 # or rediss:// for FalkorDB Cloud
102
+ export FALKORDB_PASSWORD=falkordb
103
+ ctoai connect --backfill
104
+ ```
105
+
106
+ Credentials stay in env vars; `config.json` stores only the URL, graph name, and user. The adapter speaks RESP directly, so there is no client-library dependency.
107
+
108
+ ## Development
109
+
110
+ ```bash
111
+ npm install
112
+ npm run verify # lint + typecheck + test + build
113
+ node dist/cli.js --help
114
+ ```
115
+
116
+ If the `ctoai` command goes missing or looks stale after changes, rebuild and re-link:
117
+
118
+ ```bash
119
+ npm run build && npm link
120
+ ```
121
+
122
+ ## Layout
123
+
124
+ - `src/cli.ts` — the command surface (commander).
125
+ - `src/core/` — config, paths, errors with stable codes, the append-only event log, deterministic JSON.
126
+ - `src/scan/` — gitignore-aware walker, import scanner, markdown scanner.
127
+ - `src/index/` — the index builder and the in-memory graph algorithms.
128
+ - `src/tools/` — the fixed tool catalogue and the `ToolContext` every tool receives.
129
+ - `src/commands/` — one module per command.
130
+ - `src/spec/` — the spec-driven build-plan workflow.
131
+ - `src/project/` — opening a project: config, store selection, event log.
132
+ - `src/stores/` — `file/` (JSONL) and `falkor/` (Cypher over RESP).
133
+ - `tests/` — vitest suites: scanner, graph, tools, events, and command integration.
134
+
135
+ ## License
136
+
137
+ MIT