@codragraph/cli 1.6.4 → 2.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 +34 -0
- package/dist/_shared/cgdb/schema-constants.d.ts +16 -0
- package/dist/_shared/cgdb/schema-constants.d.ts.map +1 -0
- package/dist/_shared/cgdb/schema-constants.js +67 -0
- package/dist/_shared/cgdb/schema-constants.js.map +1 -0
- package/dist/_shared/index.d.ts +2 -2
- package/dist/_shared/index.js +1 -1
- package/dist/cli/analyze.d.ts +22 -0
- package/dist/cli/analyze.js +109 -6
- package/dist/cli/compress-stats.d.ts +29 -0
- package/dist/cli/compress-stats.js +97 -0
- package/dist/cli/graphstore.d.ts +6 -2
- package/dist/cli/graphstore.js +45 -23
- package/dist/cli/index-repo.js +3 -3
- package/dist/cli/index.js +16 -2
- package/dist/cli/profile-heap.d.ts +35 -0
- package/dist/cli/profile-heap.js +126 -0
- package/dist/cli/setup.d.ts +13 -0
- package/dist/cli/setup.js +22 -11
- package/dist/cli/skill-gen.d.ts +14 -2
- package/dist/cli/skill-gen.js +52 -19
- package/dist/cli/tool.js +4 -0
- package/dist/cli/wiki.js +3 -3
- package/dist/core/augmentation/engine.js +7 -7
- package/dist/core/cgdb/cgdb-adapter.d.ts +176 -0
- package/dist/core/cgdb/cgdb-adapter.js +1320 -0
- package/dist/core/cgdb/content-read.d.ts +46 -0
- package/dist/core/cgdb/content-read.js +64 -0
- package/dist/core/cgdb/csv-generator.d.ts +29 -0
- package/dist/core/cgdb/csv-generator.js +492 -0
- package/dist/core/cgdb/pool-adapter.d.ts +93 -0
- package/dist/core/cgdb/pool-adapter.js +550 -0
- package/dist/core/cgdb/schema.d.ts +62 -0
- package/dist/core/cgdb/schema.js +502 -0
- package/dist/core/embeddings/embedding-pipeline.js +27 -10
- package/dist/core/graphstore/cgdb-row-source.d.ts +19 -0
- package/dist/core/graphstore/cgdb-row-source.js +141 -0
- package/dist/core/graphstore/index.d.ts +1 -1
- package/dist/core/graphstore/index.js +3 -3
- package/dist/core/group/bridge-db.d.ts +2 -2
- package/dist/core/group/bridge-db.js +123 -36
- package/dist/core/group/bridge-schema.d.ts +4 -4
- package/dist/core/group/bridge-schema.js +4 -4
- package/dist/core/group/cross-impact.js +3 -3
- package/dist/core/group/sync.js +4 -4
- package/dist/core/lbug/content-read.d.ts +46 -0
- package/dist/core/lbug/content-read.js +64 -0
- package/dist/core/lbug/csv-generator.d.ts +2 -6
- package/dist/core/lbug/csv-generator.js +45 -12
- package/dist/core/lbug/lbug-adapter.d.ts +4 -1
- package/dist/core/lbug/lbug-adapter.js +153 -21
- package/dist/core/lbug/schema.d.ts +7 -7
- package/dist/core/lbug/schema.js +18 -0
- package/dist/core/run-analyze.d.ts +13 -0
- package/dist/core/run-analyze.js +114 -27
- package/dist/core/search/bm25-index.d.ts +3 -3
- package/dist/core/search/bm25-index.js +75 -23
- package/dist/core/search/hybrid-search.js +2 -2
- package/dist/core/wiki/generator.d.ts +2 -2
- package/dist/core/wiki/generator.js +4 -4
- package/dist/core/wiki/graph-queries.d.ts +2 -2
- package/dist/core/wiki/graph-queries.js +5 -5
- package/dist/mcp/core/cgdb-adapter.d.ts +5 -0
- package/dist/mcp/core/cgdb-adapter.js +5 -0
- package/dist/mcp/core/embedder.js +1 -1
- package/dist/mcp/local/local-backend.d.ts +2 -2
- package/dist/mcp/local/local-backend.js +36 -19
- package/dist/mcp/server.js +3 -3
- package/dist/mcp/tools.js +1 -1
- package/dist/server/analyze-worker.js +2 -2
- package/dist/server/api.js +34 -33
- package/dist/storage/repo-manager.d.ts +42 -3
- package/dist/storage/repo-manager.js +23 -4
- package/hooks/claude/codragraph-hook.cjs +98 -5
- package/package.json +4 -4
- package/scripts/build-tree-sitter-proto.cjs +15 -3
- package/scripts/build.js +8 -9
- package/scripts/patch-tree-sitter-swift.cjs +17 -4
- package/skills/codragraph-api-surface.md +110 -0
- package/skills/codragraph-config-audit.md +146 -0
- package/skills/codragraph-cross-repo-impact.md +135 -0
- package/skills/codragraph-data-lineage.md +137 -0
- package/skills/codragraph-dead-code.md +119 -0
- package/skills/codragraph-gh-actions-debug.md +162 -0
- package/skills/codragraph-gh-issue-workflow.md +178 -0
- package/skills/codragraph-gh-pr-workflow.md +176 -0
- package/skills/codragraph-gh-release-workflow.md +187 -0
- package/skills/codragraph-git-bisect.md +176 -0
- package/skills/codragraph-git-force-push.md +147 -0
- package/skills/codragraph-git-history-rewrite.md +174 -0
- package/skills/codragraph-git-rebase-vs-merge.md +138 -0
- package/skills/codragraph-git-recovery.md +181 -0
- package/skills/codragraph-git-worktree.md +145 -0
- package/skills/codragraph-migration-tracking.md +130 -0
- package/skills/codragraph-notebook-context.md +136 -0
- package/skills/codragraph-observability-coverage.md +125 -0
- package/skills/codragraph-onboarding.md +129 -0
- package/skills/codragraph-perf-hotspots.md +132 -0
- package/skills/codragraph-project-switcher.md +116 -0
- package/skills/codragraph-security-audit.md +144 -0
- package/skills/codragraph-sql-tracing.md +122 -0
- package/skills/codragraph-supply-chain-audit.md +153 -0
- package/skills/codragraph-test-coverage.md +97 -0
- package/vendor/tree-sitter-proto/bindings/node/index.js +3 -3
- package/vendor/tree-sitter-proto/src/node-types.json +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codragraph-data-lineage
|
|
3
|
+
description: "Use when tracing data flow through an ETL pipeline, finding where a column or table is read/written, mapping data dependencies in a notebook-heavy or data-engineering project. Examples: \"where does this data come from\", \"trace this column\", \"data lineage for X\", \"who reads from this table\", \"what's downstream of this query\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Data Lineage with CodraGraph
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "Where does the `user_events` table get written?"
|
|
11
|
+
- "Trace the data flow that produces `daily_revenue.csv`"
|
|
12
|
+
- "What's downstream of this Snowflake query?"
|
|
13
|
+
- "Which notebook cells transform this DataFrame?"
|
|
14
|
+
- Auditing a data pipeline before changing a schema
|
|
15
|
+
- Understanding an unfamiliar ETL project
|
|
16
|
+
|
|
17
|
+
## Why CodraGraph helps here
|
|
18
|
+
|
|
19
|
+
Data pipelines often look like a graph of small functions: `extract_*`,
|
|
20
|
+
`transform_*`, `load_*`, `enrich_*`. Their connections are *function calls*
|
|
21
|
+
plus *string-literal table names* and *file paths*. CodraGraph already
|
|
22
|
+
captures the call graph; combining it with `query` over identifier strings
|
|
23
|
+
gives you data lineage at the *symbol* level, regardless of whether your
|
|
24
|
+
pipeline is in vanilla Python, Airflow, dbt, Pandas, PySpark, or Notebooks.
|
|
25
|
+
|
|
26
|
+
## Workflow
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
1. codragraph_query({query: "<table_or_column_name>"})
|
|
30
|
+
→ find every symbol that mentions the data identifier
|
|
31
|
+
|
|
32
|
+
2. For each candidate symbol:
|
|
33
|
+
codragraph_context({name: "<symbol>"})
|
|
34
|
+
→ see callers (who triggers this read/write) and callees (what it depends on)
|
|
35
|
+
|
|
36
|
+
3. Walk the producer side (downstream → upstream):
|
|
37
|
+
codragraph_impact({target: "<load function>", direction: "upstream"})
|
|
38
|
+
→ trace back to where the data originates
|
|
39
|
+
|
|
40
|
+
4. Walk the consumer side (upstream → downstream):
|
|
41
|
+
codragraph_impact({target: "<extract function>", direction: "downstream"})
|
|
42
|
+
→ trace forward to every transform / sink that depends on it
|
|
43
|
+
|
|
44
|
+
5. READ codragraph://repo/{name}/process/<pipeline-flow>
|
|
45
|
+
→ the canonical step-by-step flow if CodraGraph detected this as a process
|
|
46
|
+
|
|
47
|
+
6. Build the lineage diagram: source → transform stages → sink
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
> CodraGraph is graph-aware, not SQL-aware: it sees a string literal that
|
|
51
|
+
> *looks* like a table name, but doesn't parse SQL semantics. For mature SQL
|
|
52
|
+
> lineage tooling (column-level resolution), pair with `codragraph-sql-tracing`
|
|
53
|
+
> skill and a SQL parser like sqlglot.
|
|
54
|
+
|
|
55
|
+
## Checklist
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
- [ ] query for the table/column/file identifier
|
|
59
|
+
- [ ] context on each candidate to map producers vs consumers
|
|
60
|
+
- [ ] impact upstream on the load/sink function
|
|
61
|
+
- [ ] impact downstream on the extract/source function
|
|
62
|
+
- [ ] Cross-reference with processes for canonical pipeline flows
|
|
63
|
+
- [ ] Render the lineage as: source → transform_1 → transform_2 → sink
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Identifier Patterns to Search
|
|
67
|
+
|
|
68
|
+
| Layer | Search hints |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| File-based source | filename, path fragments (`raw_events.parquet`) |
|
|
71
|
+
| Database table | bare table name + `FROM table_name` |
|
|
72
|
+
| Column / field | column name in conjunction with the table name |
|
|
73
|
+
| API endpoint | URL path or function name (`fetchUserEvents`) |
|
|
74
|
+
| Event topic / queue | topic name (`user.signup.v2`) |
|
|
75
|
+
|
|
76
|
+
## Example: "Where does daily_revenue.csv come from?"
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
1. codragraph_query({query: "daily_revenue"})
|
|
80
|
+
→ 4 symbols:
|
|
81
|
+
- write_daily_revenue (src/etl/daily.py)
|
|
82
|
+
- read_daily_revenue (src/dashboards/finance.py)
|
|
83
|
+
- DailyRevenueRow (src/schemas/types.py)
|
|
84
|
+
- daily_revenue_dag (airflow/dags/finance_etl.py)
|
|
85
|
+
|
|
86
|
+
2. codragraph_context({name: "write_daily_revenue"})
|
|
87
|
+
→ callers: daily_revenue_dag (Airflow task)
|
|
88
|
+
→ callees: aggregate_orders, attach_currency_rates, format_csv_row
|
|
89
|
+
|
|
90
|
+
3. codragraph_impact({target: "aggregate_orders", direction: "upstream"})
|
|
91
|
+
→ reads from: orders_raw, returns_raw (both tables)
|
|
92
|
+
|
|
93
|
+
4. codragraph_impact({target: "read_daily_revenue", direction: "downstream"})
|
|
94
|
+
→ consumed by: finance_dashboard.render(), revenue_alerts.check()
|
|
95
|
+
|
|
96
|
+
5. READ codragraph://repo/CodraGraph/process/DailyRevenueETL
|
|
97
|
+
→ 6 steps:
|
|
98
|
+
fetch_orders → fetch_returns → aggregate_orders →
|
|
99
|
+
attach_currency_rates → format_csv_row → write_daily_revenue
|
|
100
|
+
|
|
101
|
+
Lineage:
|
|
102
|
+
orders_raw, returns_raw (DB tables)
|
|
103
|
+
↓
|
|
104
|
+
fetch_orders + fetch_returns (extract)
|
|
105
|
+
↓
|
|
106
|
+
aggregate_orders → attach_currency_rates → format_csv_row (transform)
|
|
107
|
+
↓
|
|
108
|
+
daily_revenue.csv (sink)
|
|
109
|
+
↓
|
|
110
|
+
finance_dashboard, revenue_alerts (consumers)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Output Format
|
|
114
|
+
|
|
115
|
+
```markdown
|
|
116
|
+
## Data Lineage: <data-asset>
|
|
117
|
+
|
|
118
|
+
### Sources
|
|
119
|
+
- `orders_raw` (DB)
|
|
120
|
+
- `returns_raw` (DB)
|
|
121
|
+
|
|
122
|
+
### Pipeline (DailyRevenueETL flow, 6 steps)
|
|
123
|
+
1. `fetch_orders` — reads `orders_raw`
|
|
124
|
+
2. `fetch_returns` — reads `returns_raw`
|
|
125
|
+
3. `aggregate_orders` — joins, sums by day
|
|
126
|
+
4. `attach_currency_rates` — enriches with FX
|
|
127
|
+
5. `format_csv_row` — schema-conforming serialization
|
|
128
|
+
6. `write_daily_revenue` — writes `daily_revenue.csv`
|
|
129
|
+
|
|
130
|
+
### Consumers
|
|
131
|
+
- `finance_dashboard` (renders chart)
|
|
132
|
+
- `revenue_alerts` (threshold checks)
|
|
133
|
+
|
|
134
|
+
### Risk if `<schema/source>` changes
|
|
135
|
+
- 6 transform stages depend on it
|
|
136
|
+
- 2 consumers depend on the output schema
|
|
137
|
+
```
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codragraph-dead-code
|
|
3
|
+
description: "Use when the user wants to find unused code, orphan functions/classes, dead code, or symbols safe to delete. Examples: \"what's unused\", \"find dead code\", \"can I delete this function\", \"orphan symbols\", \"clean up unused exports\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dead Code Detection with CodraGraph
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "What's unused in this codebase?"
|
|
11
|
+
- "Find dead code / orphan functions / unused exports"
|
|
12
|
+
- "Can I safely delete `<symbol>`?"
|
|
13
|
+
- Periodic cleanup before a release
|
|
14
|
+
- Identifying candidates for the next refactor
|
|
15
|
+
|
|
16
|
+
## Why CodraGraph helps here
|
|
17
|
+
|
|
18
|
+
Linters can find unreachable code in *one file*. CodraGraph walks the
|
|
19
|
+
*whole-repo* call graph, including dynamic dispatch, framework entry
|
|
20
|
+
points, and exports — so it can tell you a symbol is genuinely unreachable
|
|
21
|
+
rather than just "the linter couldn't see the caller."
|
|
22
|
+
|
|
23
|
+
The trick is to combine three signals:
|
|
24
|
+
|
|
25
|
+
1. **No incoming references** — `cypher` query for symbols with zero
|
|
26
|
+
`<-[:CALLS|REFERENCES]-` edges.
|
|
27
|
+
2. **Not exported** — internal-only symbols are stronger candidates than
|
|
28
|
+
`isExported = true` ones (which may be public API).
|
|
29
|
+
3. **Not in any process** — execution flows are the canonical "this is
|
|
30
|
+
used" signal; symbols outside every process are extra suspect.
|
|
31
|
+
|
|
32
|
+
## Workflow
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
1. codragraph_cypher({query: `
|
|
36
|
+
MATCH (n)
|
|
37
|
+
WHERE NOT (n)<-[:CALLS|REFERENCES]-()
|
|
38
|
+
AND NOT (n.isExported = true)
|
|
39
|
+
RETURN n.id, n.name, labels(n)[0] AS label, n.filePath
|
|
40
|
+
LIMIT 200
|
|
41
|
+
`})
|
|
42
|
+
→ list of orphan candidates
|
|
43
|
+
|
|
44
|
+
2. For each candidate:
|
|
45
|
+
codragraph_context({name: "<candidate>"})
|
|
46
|
+
→ confirm: 0 callers, 0 callees that matter, not in any process
|
|
47
|
+
|
|
48
|
+
3. Cross-check against processes:
|
|
49
|
+
READ codragraph://repo/{name}/processes
|
|
50
|
+
→ if the symbol appears in ANY process, it's not actually dead
|
|
51
|
+
|
|
52
|
+
4. For exported orphans (potentially public API):
|
|
53
|
+
codragraph_impact({target: "<symbol>", direction: "upstream"})
|
|
54
|
+
→ if d=1 has external callers (in another indexed repo group), keep it
|
|
55
|
+
|
|
56
|
+
5. Group by file/cluster, prioritize by file size of dead code
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
> If "Index is stale" → run `npx @codragraph/cli analyze` first. Stale
|
|
60
|
+
> indexes produce false-positive dead-code reports because new callers
|
|
61
|
+
> aren't visible.
|
|
62
|
+
|
|
63
|
+
## Checklist
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
- [ ] Cypher query for orphan symbols (no incoming edges, not exported)
|
|
67
|
+
- [ ] context check on each candidate (confirm 0 callers)
|
|
68
|
+
- [ ] Cross-reference with processes (symbols in flows are not dead)
|
|
69
|
+
- [ ] For exported orphans, impact across groups (cross-repo callers?)
|
|
70
|
+
- [ ] Group findings by file → suggest which files can lose the most code
|
|
71
|
+
- [ ] Flag any candidate that's a framework convention (e.g., default export
|
|
72
|
+
of a Next.js page route) — those LOOK orphan but aren't
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Pitfalls
|
|
76
|
+
|
|
77
|
+
| Pitfall | What to do |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| Framework conventions (Next.js pages, Astro routes, Django URLs) | Check `isEntryPoint` on the node — these often score high |
|
|
80
|
+
| Test-only symbols | Filter `filePath CONTAINS '/test'` separately |
|
|
81
|
+
| Re-exported symbols | A re-export creates `REFERENCES` edges; a true orphan has none |
|
|
82
|
+
| Dynamic dispatch (factories, plugin systems) | Cross-check with `query` for the registration string |
|
|
83
|
+
|
|
84
|
+
## Example: "Clean up unused code in src/utils/"
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
1. codragraph_cypher({
|
|
88
|
+
query: `MATCH (n) WHERE n.filePath STARTS WITH 'src/utils/'
|
|
89
|
+
AND NOT (n)<-[:CALLS|REFERENCES]-()
|
|
90
|
+
AND NOT (n.isExported = true)
|
|
91
|
+
RETURN n.id, n.name, n.filePath`
|
|
92
|
+
})
|
|
93
|
+
→ 7 candidates
|
|
94
|
+
|
|
95
|
+
2. codragraph_context({name: "formatLegacyDate"})
|
|
96
|
+
→ 0 callers, 0 callees, not in any process. Truly dead.
|
|
97
|
+
|
|
98
|
+
3. codragraph_context({name: "DEBUG_TIMER"})
|
|
99
|
+
→ 0 callers but called dynamically via process.env injection.
|
|
100
|
+
→ Keep it.
|
|
101
|
+
|
|
102
|
+
4. Final: 6 of 7 candidates safe to delete. Total: 142 LoC across 4 files.
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Output Format
|
|
106
|
+
|
|
107
|
+
```markdown
|
|
108
|
+
## Dead Code Audit: <scope>
|
|
109
|
+
|
|
110
|
+
### High-confidence (0 callers, 0 callees, not in any process)
|
|
111
|
+
- `formatLegacyDate` — `src/utils/date.ts:42` (12 LoC)
|
|
112
|
+
- ...
|
|
113
|
+
|
|
114
|
+
### Possibly dead (verify dynamic dispatch first)
|
|
115
|
+
- `DEBUG_TIMER` — used via env-driven hook?
|
|
116
|
+
|
|
117
|
+
### Total cleanup potential
|
|
118
|
+
N functions, M LoC, X files.
|
|
119
|
+
```
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codragraph-gh-actions-debug
|
|
3
|
+
description: "Use when a GitHub Actions workflow fails, needs to be re-run, dispatched manually, or inspected. Covers `gh run` for inspecting/rerunning runs, `gh workflow` for triggering, secrets, and the most common failure modes. Examples: \"why did CI fail\", \"rerun this workflow\", \"dispatch a workflow manually\", \"debug GitHub Action\", \"set GitHub secret\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GitHub Actions Debugging with `gh`
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "CI failed on my PR — show me why."
|
|
11
|
+
- "Rerun the failed jobs only."
|
|
12
|
+
- "Dispatch a workflow manually with custom inputs."
|
|
13
|
+
- "Add or rotate a secret."
|
|
14
|
+
- "Cancel a hung workflow run."
|
|
15
|
+
|
|
16
|
+
## Lifecycle commands
|
|
17
|
+
|
|
18
|
+
### List / inspect runs
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
gh run list # most recent runs
|
|
22
|
+
gh run list --workflow ci.yml # one workflow's runs
|
|
23
|
+
gh run list --branch my-feature --status failure # failed runs on a branch
|
|
24
|
+
gh run list --json conclusion,databaseId,headBranch,name --jq '.[] | select(.conclusion=="failure")'
|
|
25
|
+
|
|
26
|
+
gh run view <run-id> # run summary + jobs
|
|
27
|
+
gh run view <run-id> --log # FULL logs (verbose)
|
|
28
|
+
gh run view <run-id> --log-failed # only the failed steps' logs
|
|
29
|
+
gh run view <run-id> --json jobs --jq '.jobs[] | {name, conclusion}'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
If you don't know the run id:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Most recent run on current branch:
|
|
36
|
+
gh run view --branch "$(git branch --show-current)"
|
|
37
|
+
|
|
38
|
+
# Most recent failed run anywhere:
|
|
39
|
+
gh run list --status failure --limit 1 --json databaseId --jq '.[0].databaseId'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Re-run
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
gh run rerun <run-id> # rerun the WHOLE run
|
|
46
|
+
gh run rerun <run-id> --failed # only the failed jobs
|
|
47
|
+
gh run rerun <run-id> --job <job-id> # only one specific job
|
|
48
|
+
gh run rerun <run-id> --debug # enable runner debug logging
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`--failed` is the right default for "I think the failure was flaky."
|
|
52
|
+
|
|
53
|
+
### Cancel / delete
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
gh run cancel <run-id> # cancel an in-progress run
|
|
57
|
+
gh run delete <run-id> # remove from history (rare)
|
|
58
|
+
gh run watch <run-id> # tail the run live
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Manual dispatch (workflow_dispatch)
|
|
62
|
+
|
|
63
|
+
For workflows with `on: workflow_dispatch:`:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
gh workflow list # which workflows are dispatchable
|
|
67
|
+
gh workflow run <workflow-name-or-id> # run on default branch
|
|
68
|
+
gh workflow run ci.yml --ref my-branch # run on a specific branch
|
|
69
|
+
gh workflow run deploy.yml --field environment=staging --field version=1.7.0
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Re-list runs to see the dispatched one:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
gh run list --workflow ci.yml --limit 5
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Secrets and variables
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Repo-scope secrets:
|
|
82
|
+
gh secret list
|
|
83
|
+
gh secret set ANTHROPIC_API_KEY --body "sk-…"
|
|
84
|
+
gh secret set ANTHROPIC_API_KEY < ~/api-key.txt # from file
|
|
85
|
+
gh secret delete OLD_KEY
|
|
86
|
+
|
|
87
|
+
# Repo-scope variables (non-secret):
|
|
88
|
+
gh variable list
|
|
89
|
+
gh variable set DEPLOY_REGION --body "us-east-1"
|
|
90
|
+
|
|
91
|
+
# Environment-scope (e.g., production):
|
|
92
|
+
gh secret set MY_KEY --env production --body "…"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Why CodraGraph helps here
|
|
96
|
+
|
|
97
|
+
When a workflow YAML changes break CI, treat the workflow as code: the
|
|
98
|
+
PR review Action's structural diff doesn't help (Actions aren't TS/Python),
|
|
99
|
+
but two CodraGraph patterns DO help:
|
|
100
|
+
|
|
101
|
+
1. **Find the symbol the workflow invokes** — many workflows call into
|
|
102
|
+
the codebase (`npm test`, `npx my-cli`, `python scripts/foo.py`).
|
|
103
|
+
Trace what each step actually executes:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
codragraph_query({query: "<command the action runs, e.g. 'analyze repo'>"})
|
|
107
|
+
→ which CLI handler / script the workflow ends up running
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
2. **After a CI break, diff against the last green run's commit** — was
|
|
111
|
+
it a code change or a workflow YAML change?
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
gh run list --workflow ci.yml --status success --limit 1 --json headSha
|
|
115
|
+
→ <last-green-sha>
|
|
116
|
+
|
|
117
|
+
codragraph diff <last-green-sha> HEAD --semantic
|
|
118
|
+
→ if structural diff is empty, the break is in YAML / env / runner — not code
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Failure-mode triage
|
|
122
|
+
|
|
123
|
+
| Symptom | Likely cause | Where to look |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| `npm install` fails on Linux only | Native deps need apt packages | Add `apt-get install` step or use a different runner |
|
|
126
|
+
| Tests pass locally, fail in CI | Env diff (Node version, locale, timezone) | Compare runner env vs local; add `node-version` matrix |
|
|
127
|
+
| Workflow re-runs with no code change still fail | Flaky test or external service | `gh run rerun --failed --debug` and read the debug logs |
|
|
128
|
+
| Action can't see secret | Secret scope mismatch | `gh secret list` per env / repo / org; secrets don't leak across environments |
|
|
129
|
+
| Pull-request workflow can't write | Default `GITHUB_TOKEN` is read-only on PRs from forks | Switch to `pull_request_target` (with care) or PAT-based action |
|
|
130
|
+
|
|
131
|
+
## Debugging steps that actually work
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# 1. Re-run with debug:
|
|
135
|
+
gh run rerun <run-id> --failed --debug
|
|
136
|
+
|
|
137
|
+
# 2. Tail the live run:
|
|
138
|
+
gh run watch <run-id>
|
|
139
|
+
|
|
140
|
+
# 3. Pull only the failed step's logs:
|
|
141
|
+
gh run view <run-id> --log-failed | less
|
|
142
|
+
|
|
143
|
+
# 4. If you need full context, download artifacts:
|
|
144
|
+
gh run download <run-id>
|
|
145
|
+
ls ./
|
|
146
|
+
|
|
147
|
+
# 5. To enable verbose runner logs without re-running, set repo secrets:
|
|
148
|
+
gh secret set ACTIONS_RUNNER_DEBUG --body "true"
|
|
149
|
+
gh secret set ACTIONS_STEP_DEBUG --body "true"
|
|
150
|
+
# (re-run the workflow to pick these up)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Pitfalls
|
|
154
|
+
|
|
155
|
+
| Pitfall | Symptom | Fix |
|
|
156
|
+
|---|---|---|
|
|
157
|
+
| `--debug` doesn't show extra logs | Repo doesn't have the debug secrets set | Set `ACTIONS_STEP_DEBUG=true` repo secret |
|
|
158
|
+
| Workflow doesn't appear in dispatch list | Missing `on: workflow_dispatch:` | Add the trigger to the workflow YAML |
|
|
159
|
+
| Inputs to dispatch silently ignored | Type mismatch or missing `inputs:` block | Re-check the workflow YAML's `inputs:` schema |
|
|
160
|
+
| Re-run doesn't pick up your fix | Re-run uses the SAME commit; you need a NEW push for the new code | Push a fix; or use `--debug` if you want runner-level debugging only |
|
|
161
|
+
| Secrets leaked in logs | Used `${{ secrets.X }}` in a `run:` step that echoes | Use env: with secret values; never echo |
|
|
162
|
+
```
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codragraph-gh-issue-workflow
|
|
3
|
+
description: "Use for issue management via GitHub CLI — create, triage, label, assign, link to PRs, manage projects (v2), close with reason. Examples: \"open an issue\", \"triage issues\", \"add labels\", \"link this PR to issue\", \"close issue\", \"manage GitHub projects\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Issue Workflow with `gh`
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "Open an issue for this bug."
|
|
11
|
+
- "Triage the open issues — sort by labels / priority."
|
|
12
|
+
- "Link this PR to issue #42 so it auto-closes on merge."
|
|
13
|
+
- "Add this issue to my project board."
|
|
14
|
+
- "Bulk-relabel old issues."
|
|
15
|
+
|
|
16
|
+
## Lifecycle commands
|
|
17
|
+
|
|
18
|
+
### Create
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Quick create:
|
|
22
|
+
gh issue create --title "…" --body "…" --label bug --assignee "@me"
|
|
23
|
+
|
|
24
|
+
# Multi-line body via HEREDOC:
|
|
25
|
+
gh issue create --title "Auth times out after 30s" --body "$(cat <<'EOF'
|
|
26
|
+
## Repro
|
|
27
|
+
1. Login as user X
|
|
28
|
+
2. Wait 30s
|
|
29
|
+
3. Click anywhere
|
|
30
|
+
|
|
31
|
+
## Expected
|
|
32
|
+
Session refresh transparent.
|
|
33
|
+
|
|
34
|
+
## Actual
|
|
35
|
+
Hard logout with no warning.
|
|
36
|
+
|
|
37
|
+
## Environment
|
|
38
|
+
- App version: …
|
|
39
|
+
- Browser: …
|
|
40
|
+
EOF
|
|
41
|
+
)"
|
|
42
|
+
|
|
43
|
+
# From a template (.github/ISSUE_TEMPLATE/<x>.md):
|
|
44
|
+
gh issue create --template bug_report.md
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### List / search / view
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
gh issue list # open issues
|
|
51
|
+
gh issue list --state all --limit 100 # everything
|
|
52
|
+
gh issue list --label "bug,priority:high" # filter
|
|
53
|
+
gh issue list --search "in:title auth" # full-text in title/body
|
|
54
|
+
gh issue list --assignee "@me" # assigned to you
|
|
55
|
+
|
|
56
|
+
gh issue view <N> # one issue
|
|
57
|
+
gh issue view <N> --comments # include comments
|
|
58
|
+
gh issue status # issues needing your attention
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Triage / edit
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
gh issue edit <N> --add-label "bug,needs-repro" --add-assignee @teammate
|
|
65
|
+
gh issue edit <N> --remove-label "stale" --milestone "v1.7.0"
|
|
66
|
+
gh issue comment <N> --body "Cannot repro. Could you share <X>?"
|
|
67
|
+
gh issue pin <N> # pin to top of issues page
|
|
68
|
+
gh issue unpin <N>
|
|
69
|
+
gh issue lock <N> # freeze further comments
|
|
70
|
+
gh issue unlock <N>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Link issues to PRs
|
|
74
|
+
|
|
75
|
+
GitHub auto-closes the issue when a PR with `Closes #N` / `Fixes #N` /
|
|
76
|
+
`Resolves #N` in the body merges. From the CLI:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
gh pr create --body "$(cat <<'EOF'
|
|
80
|
+
Fixes #42.
|
|
81
|
+
|
|
82
|
+
## Summary
|
|
83
|
+
…
|
|
84
|
+
EOF
|
|
85
|
+
)"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
For sub-issues / dependencies (no auto-close, just visual link):
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Related: #43, #44
|
|
92
|
+
Blocks: #50
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Close / reopen
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# State reasons (GitHub Issue State Reasons API):
|
|
99
|
+
gh issue close <N> --reason completed # default
|
|
100
|
+
gh issue close <N> --reason "not planned" # won't fix
|
|
101
|
+
gh issue close <N> --reason duplicate --comment "duplicate of #M"
|
|
102
|
+
|
|
103
|
+
gh issue reopen <N>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Triage workflow (recurring)
|
|
107
|
+
|
|
108
|
+
A weekly / per-stand-up triage pass:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# 1. Surface issues with no labels (the worst offender):
|
|
112
|
+
gh issue list --search "no:label" --limit 50
|
|
113
|
+
|
|
114
|
+
# 2. Surface "needs repro" stale-bait:
|
|
115
|
+
gh issue list --label "needs-repro" \
|
|
116
|
+
--search "updated:<$(date -u -d '14 days ago' +%Y-%m-%d)" --limit 50
|
|
117
|
+
|
|
118
|
+
# 3. Bulk-label or bulk-close (loop with gh):
|
|
119
|
+
for n in $(gh issue list --label "needs-repro" \
|
|
120
|
+
--search "updated:<$(date -u -d '30 days ago' +%Y-%m-%d)" \
|
|
121
|
+
--json number --jq '.[].number'); do
|
|
122
|
+
gh issue close "$n" --reason "not planned" \
|
|
123
|
+
--comment "Closing for inactivity. Reopen with a fresh repro."
|
|
124
|
+
done
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Projects (v2)
|
|
128
|
+
|
|
129
|
+
GitHub Projects v2 is the modern board. The CLI has first-class support
|
|
130
|
+
via `gh project`:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
gh project list --owner <org-or-user>
|
|
134
|
+
gh project view <number> --owner <org> # full board contents
|
|
135
|
+
gh project item-add <project-number> --owner <org> --url <issue-url>
|
|
136
|
+
gh project item-edit --id <item-id> --field-id <fid> --single-select-option-id <oid>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Adding from issue context (one-liner):
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
gh project item-add <pn> --owner <org> --url $(gh issue view <N> --json url --jq .url)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Why CodraGraph helps here
|
|
146
|
+
|
|
147
|
+
When triaging a bug, jump straight from issue text to the suspect code:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
1. gh issue view 42 --comments
|
|
151
|
+
→ "validateUser fails for users with X"
|
|
152
|
+
|
|
153
|
+
2. codragraph_query({query: "validateUser X"})
|
|
154
|
+
→ suspect symbols ranked
|
|
155
|
+
|
|
156
|
+
3. codragraph_context({name: "validateUser"})
|
|
157
|
+
→ callers + callees + processes
|
|
158
|
+
|
|
159
|
+
4. codragraph_impact({target: "validateUser", direction: "upstream"})
|
|
160
|
+
→ which flows are affected — confirms the bug's blast radius
|
|
161
|
+
|
|
162
|
+
5. Comment on the issue with concrete next steps:
|
|
163
|
+
gh issue comment 42 --body "Fix likely in src/auth/validate.ts:42 …"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Combine with the `codragraph-debugging` skill for full bug-investigation
|
|
167
|
+
workflow.
|
|
168
|
+
|
|
169
|
+
## Pitfalls
|
|
170
|
+
|
|
171
|
+
| Pitfall | Fix |
|
|
172
|
+
|---|---|
|
|
173
|
+
| Issue body forgets the repro | Always include "Repro / Expected / Actual / Env" in the template |
|
|
174
|
+
| Closing without a reason | Use `--reason "not planned"` so the state is searchable |
|
|
175
|
+
| Linking to PR via `#N` only | Use `Fixes #N` in PR body — that's what triggers auto-close |
|
|
176
|
+
| Bulk-relabeling without a `--dry-run` | gh has no built-in dry run; do `gh issue list` first to preview |
|
|
177
|
+
| Mixing v1 boards (deprecated) and v2 | New automation: only `gh project` (v2). Old `gh project` v1 commands removed in CLI 2.20+ |
|
|
178
|
+
```
|