* feat(01-01): create graphify.cjs library module with config gate, subprocess helper, presence detection, and version check - isGraphifyEnabled() gates on config.graphify.enabled in .planning/config.json - disabledResponse() returns structured disabled message with enable instructions - execGraphify() wraps spawnSync with PYTHONUNBUFFERED=1, 30s timeout, ENOENT/SIGTERM handling - checkGraphifyInstalled() detects missing binary via --help probe - checkGraphifyVersion() uses python3 importlib.metadata, validates >=0.4.0,<1.0 range * feat(01-01): register graphify.enabled in VALID_CONFIG_KEYS - Added graphify.enabled after intel.enabled in config.cjs VALID_CONFIG_KEYS Set - Enables gsd-tools config-set graphify.enabled true without key rejection * test(01-02): add comprehensive unit tests for graphify.cjs module - 23 tests covering all 5 exported functions across 5 describe blocks - Config gate tests: enabled/disabled/missing/malformed scenarios (TEST-03, FOUND-01) - Subprocess tests: success, ENOENT, timeout, env vars, timeout override (FOUND-04) - Presence tests: --help detection, install instructions (FOUND-02, TEST-04) - Version tests: compatible/incompatible/unparseable/missing (FOUND-03, TEST-04) - Fix graphify.cjs to use childProcess.spawnSync (not destructured) for testability * feat(02-01): add graphifyQuery, graphifyStatus, graphifyDiff to graphify.cjs - safeReadJson wraps JSON.parse in try/catch, returns null on failure - buildAdjacencyMap creates bidirectional adjacency map from graph nodes/edges - seedAndExpand matches on label+description (case-insensitive), BFS-expands up to maxHops - applyBudget uses chars/4 token estimation, drops AMBIGUOUS then INFERRED edges - graphifyQuery gates on config, reads graph.json, supports --budget option - graphifyStatus returns exists/last_build/counts/staleness or no-graph message - graphifyDiff compares current graph.json against .last-build-snapshot.json * feat(02-01): add case 'graphify' routing block to gsd-tools.cjs - Routes query/status/diff/build subcommands to graphify.cjs handlers - Query supports --budget flag via args.indexOf parsing - Build returns Phase 3 placeholder error message - Unknown subcommand lists all 4 available options * feat(02-01): create commands/gsd/graphify.md command definition - YAML frontmatter with name, description, argument-hint, allowed-tools - Config gate reads .planning/config.json directly (not gsd-tools config get-value) - Inline CLI calls for query/status/diff subcommands - Agent spawn placeholder for build subcommand - Anti-read warning and anti-patterns section * test(02-02): add Phase 2 test scaffolding with fixture helpers and describe blocks - Import 7 Phase 2 exports (graphifyQuery, graphifyStatus, graphifyDiff, safeReadJson, buildAdjacencyMap, seedAndExpand, applyBudget) - Add writeGraphJson and writeSnapshotJson fixture helpers - Add SAMPLE_GRAPH constant with 5 nodes, 5 edges across all confidence tiers - Scaffold 7 new describe blocks for Phase 2 functions * test(02-02): add comprehensive unit tests for all Phase 2 graphify.cjs functions - safeReadJson: valid JSON, malformed JSON, missing file (3 tests) - buildAdjacencyMap: bidirectional entries, orphan nodes, edge objects (3 tests) - seedAndExpand: label match, description match, BFS depth, empty results, maxHops (5 tests) - applyBudget: no budget passthrough, AMBIGUOUS drop, INFERRED drop, trimmed footer (4 tests) - graphifyQuery: disabled gate, no graph, valid query, confidence tiers, budget, counts (6 tests) - graphifyStatus: disabled gate, no graph, counts with graph, hyperedge count (4 tests) - graphifyDiff: disabled gate, no baseline, no graph, added/removed, changed (5 tests) - Requirements: TEST-01, QUERY-01..03, STAT-01..02, DIFF-01..02 - Full suite: 53 graphify tests pass, 3666 total tests pass (0 regressions) * feat(03-01): add graphifyBuild() pre-flight, writeSnapshot(), and build_timeout config key - Add graphifyBuild(cwd) returning spawn_agent JSON with graphs_dir, timeout, version - Add writeSnapshot(cwd) reading graph.json and writing atomic .last-build-snapshot.json - Register graphify.build_timeout in VALID_CONFIG_KEYS - Import atomicWriteFileSync from core.cjs for crash-safe snapshot writes * feat(03-01): wire build routing in gsd-tools and flesh out builder agent prompt - Replace Phase 3 placeholder with graphifyBuild() and writeSnapshot() dispatch - Route 'graphify build snapshot' to writeSnapshot(), 'graphify build' to graphifyBuild() - Expand Step 3 builder agent prompt with 5-step workflow: invoke, validate, copy, snapshot, summary - Include error handling guidance: non-zero exit preserves prior .planning/graphs/ * test(03-02): add graphifyBuild test suite with 6 tests - Disabled config returns disabled response - Missing CLI returns error with install instructions - Successful pre-flight returns spawn_agent action with correct shape - Creates .planning/graphs/ directory if missing - Reads graphify.build_timeout from config (custom 600s) - Version warning included when outside tested range * test(03-02): add writeSnapshot test suite with 6 tests - Writes snapshot from existing graph.json with correct structure - Returns error when graph.json does not exist - Returns error when graph.json is invalid JSON - Handles empty nodes and edges arrays - Handles missing nodes/edges keys gracefully - Overwrites existing snapshot on incremental rebuild * feat(04-01): add load_graph_context step to gsd-planner agent - Detects .planning/graphs/graph.json via ls check - Checks graph staleness via graphify status CLI call - Queries phase-relevant context with single --budget 2000 query - Silent no-op when graph.json absent (AGENT-01) * feat(04-01): add Step 1.3 Load Graph Context to gsd-phase-researcher agent - Detects .planning/graphs/graph.json via ls check - Checks graph staleness via graphify status CLI call - Queries 2-3 capability keywords with --budget 1500 each - Silent no-op when graph.json absent (AGENT-02) * test(04-01): add AGENT-03 graceful degradation tests - 3 AGENT-03 tests: absent-graph query, status, multi-term handling - 2 D-12 integration tests: known-graph query and status structure - All 5 tests pass with existing helpers and imports
5.8 KiB
name, description, argument-hint, allowed-tools
| name | description | argument-hint | allowed-tools | |||
|---|---|---|---|---|---|---|
| gsd:graphify | Build, query, and inspect the project knowledge graph in .planning/graphs/ | [build|query <term>|status|diff] |
|
STOP -- DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by Claude Code's command system. Using the Read tool on this file wastes tokens. Begin executing Step 0 immediately.
Step 0 -- Banner
Before ANY tool calls, display this banner:
GSD > GRAPHIFY
Then proceed to Step 1.
Step 1 -- Config Gate
Check if graphify is enabled by reading .planning/config.json directly using the Read tool.
DO NOT use the gsd-tools config get-value command -- it hard-exits on missing keys.
- Read
.planning/config.jsonusing the Read tool - If the file does not exist: display the disabled message below and STOP
- Parse the JSON content. Check if
config.graphify && config.graphify.enabled === true - If
graphify.enabledis NOT explicitlytrue: display the disabled message below and STOP - If
graphify.enabledistrue: proceed to Step 2
Disabled message:
GSD > GRAPHIFY
Knowledge graph is disabled. To activate:
node $HOME/.claude/get-shit-done/bin/gsd-tools.cjs config-set graphify.enabled true
Then run /gsd-graphify build to create the initial graph.
Step 2 -- Parse Argument
Parse $ARGUMENTS to determine the operation mode:
| Argument | Action |
|---|---|
build |
Spawn graphify-builder agent (Step 3) |
query <term> |
Run inline query (Step 2a) |
status |
Run inline status check (Step 2b) |
diff |
Run inline diff check (Step 2c) |
| No argument or unknown | Show usage message |
Usage message (shown when no argument or unrecognized argument):
GSD > GRAPHIFY
Usage: /gsd-graphify <mode>
Modes:
build Build or rebuild the knowledge graph
query <term> Search the graph for a term
status Show graph freshness and statistics
diff Show changes since last build
Step 2a -- Query
Run:
node $HOME/.claude/get-shit-done/bin/gsd-tools.cjs graphify query <term>
Parse the JSON output and display results:
- If the output contains
"disabled": true, display the disabled message from Step 1 and STOP - If the output contains
"error"field, display the error message and STOP - If no nodes found, display:
No graph matches for '<term>'. Try /gsd-graphify build to create or rebuild the graph. - Otherwise, display matched nodes grouped by type, with edge relationships and confidence tiers (EXTRACTED/INFERRED/AMBIGUOUS)
STOP after displaying results. Do not spawn an agent.
Step 2b -- Status
Run:
node $HOME/.claude/get-shit-done/bin/gsd-tools.cjs graphify status
Parse the JSON output and display:
- If
exists: false, display the message field - Otherwise show last build time, node/edge/hyperedge counts, and STALE or FRESH indicator
STOP after displaying status. Do not spawn an agent.
Step 2c -- Diff
Run:
node $HOME/.claude/get-shit-done/bin/gsd-tools.cjs graphify diff
Parse the JSON output and display:
- If
no_baseline: true, display the message field - Otherwise show node and edge change counts (added/removed/changed)
If no snapshot exists, suggest running build twice (first to create, second to generate a diff baseline).
STOP after displaying diff. Do not spawn an agent.
Step 3 -- Build (Agent Spawn)
Run pre-flight check first:
PREFLIGHT=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" graphify build)
If pre-flight returns disabled: true or error, display the message and STOP.
If pre-flight returns action: "spawn_agent", display:
GSD > Spawning graphify-builder agent...
Spawn a Task:
Task(
description="Build or rebuild the project knowledge graph",
prompt="You are the graphify-builder agent. Your job is to build or rebuild the project knowledge graph using the graphify CLI.
Project root: ${CWD}
gsd-tools path: $HOME/.claude/get-shit-done/bin/gsd-tools.cjs
## Instructions
1. **Invoke graphify:**
Run from the project root:
graphify . --update
This builds the knowledge graph with SHA256 incremental caching.
Timeout: up to 5 minutes (or as configured via graphify.build_timeout).
2. **Validate output:**
Check that graphify-out/graph.json exists and is valid JSON with nodes[] and edges[] arrays.
If graphify exited non-zero or graph.json is not parseable, output:
## GRAPHIFY BUILD FAILED
Include the stderr output for debugging. Do NOT delete .planning/graphs/ -- prior valid graph remains available.
3. **Copy artifacts to .planning/graphs/:**
cp graphify-out/graph.json .planning/graphs/graph.json cp graphify-out/graph.html .planning/graphs/graph.html cp graphify-out/GRAPH_REPORT.md .planning/graphs/GRAPH_REPORT.md
These three files are the build output consumed by query, status, and diff commands.
4. **Write diff snapshot:**
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" graphify build snapshot
This creates .planning/graphs/.last-build-snapshot.json for future diff comparisons.
5. **Report build summary:**
node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" graphify status
Display the node count, edge count, and hyperedge count from the status output.
When complete, output: ## GRAPHIFY BUILD COMPLETE with the summary counts.
If something fails at any step, output: ## GRAPHIFY BUILD FAILED with details."
)
Wait for the agent to complete.
Anti-Patterns
- DO NOT spawn an agent for query/status/diff operations -- these are inline CLI calls
- DO NOT modify graph files directly -- the build agent handles writes
- DO NOT skip the config gate check
- DO NOT use gsd-tools config get-value for the config gate -- it exits on missing keys