codechart 0.1.3 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codechart",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Agent skill + CLI: maps and flowcharts of code changes for AI coding agents, in terminal, chat and HTML",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -40,7 +40,7 @@ codechart render --md - <<'EOF'
40
40
  EOF
41
41
  ```
42
42
 
43
- Commit or branch not checked out: add `--at '<sha or branch>'` so anchors are read from it. On errors, fix the spec and rerun. Stderr `no map drawn`/`no flow drawn`: skip it silently. Rare cases: [spec-guide.md](spec-guide.md), [flow-guide.md](flow-guide.md), `codechart schema [--flow]`.
43
+ For a change summary, add the same `--git`/`--since`/`--commit`/`--head` you gave `check`. Commit or branch not checked out: add `--at '<sha or branch>'` so anchors are read from it. On errors, fix the spec and rerun. A `✗` line is a claim that doesn't match the code: if your spec was wrong (status, path), fix it and rerender; if the change really differs from what you said, keep the `✗` and say so. Stderr `no map drawn`/`no flow drawn`: skip it silently. Rare cases: [spec-guide.md](spec-guide.md), [flow-guide.md](flow-guide.md), `codechart schema [--flow]`.
44
44
 
45
45
  ### Flow (one behaviour each)
46
46
 
@@ -63,7 +63,7 @@ Draw only branches you saw in the code or (plan) will build; unverified ones go
63
63
  ```
64
64
 
65
65
  - 2+ outgoing links make a decision: label ends in `?`, unique, each link labelled. "if", "else", "or" or `;` in a label hides a branch: make it a decision. Labels: verb + object, ≤ 30 chars, one action (no `+` or `and`: split into steps).
66
- - `status`: summary `existing`/`new`/`changed`; plan (`"kind": "plan"`) `existing` (keeps its anchor) or `planned`.
66
+ - `status`: summary `existing`/`new`/`changed`; plan (`"kind": "plan"`) `existing` (keeps its anchor), `planned` or `removed` (keeps its anchor). Plan: keep links that exist now; one the plan drops gets `"removed": true`.
67
67
  - Anchor every non-planned step and non-planned link leaving a decision (a link is planned if either end is, or with `"planned": true`), each its own: the path plus `match`, a distinctive piece of one line copied from the diff (no line lookup; it must be on exactly one line of the file, else drop `match` and use source `path:line`), or `path:start-end` for a block. Paths are relative to the repo root (or cwd). Never drop a failing anchor or mark it `planned`: fix it.
68
68
  - Over ~15 steps, split. `gaps`: unverified branches, unread code, what you didn't run. No keys beyond the skeleton's.
69
69
 
@@ -84,7 +84,8 @@ Draw only branches you saw in the code or (plan) will build; unverified ones go
84
84
  - One node per table, model, file, service or endpoint, never merged: `new`, `changed`, `removed`, `config` (config/env), `context` (untouched neighbour the reader needs). Under 15; tests and docs go in `omitted`.
85
85
  - `layer` required, from a small set. `kind`: `table` `enum` `model` `service` `endpoint` `component` `file` (default with `path`) `config` `other`. Migration label: `migration: <what it does>`.
86
86
  - `fields`: all you read, `change`: `added`/`removed`/`modified`; `fieldsComplete: true` only if you read the whole definition.
87
- - Edges: dependent → dependency, labelled with the column, method or key; only ones you saw or will build. `kind`: `fk` `calls` `imports` `reads` `writes` `renders` `configures` `other`.
87
+ - Optional on a `new`/`changed` node with `path`: `match`, a distinctive piece of one line from the diff, as proof (shown in the HTML).
88
+ - Edges: dependent → dependency, labelled with the column, method or key; only ones you saw or will build. `kind`: `fk` `calls` `imports` `reads` `writes` `renders` `configures` `other`. Plan: a link moved between existing nodes gets `"change": "added"`/`"removed"`; a field whose type changes gets `was` (old type).
88
89
  - Context `short`: only what you read in this task, unread goes in `gaps`; `full`: also read the definitions of entities on the map.
89
90
 
90
91
  ## 3. Reply
@@ -25,13 +25,16 @@ An invented branch is the worst failure: it destroys the user's trust in the too
25
25
  | `existing` | untouched by the change | built on unchanged; keeps its anchor |
26
26
  | `new` | added by the change | rejected |
27
27
  | `changed` | altered by the change | rejected |
28
- | `planned` | rejected | anything the plan adds or alters, including a change to an existing step |
28
+ | `planned` | rejected | anything the plan adds or alters, including a change to an existing step (keep its anchor then) |
29
+ | `removed` | rejected | a step the plan deletes; keeps its anchor, since the code exists now |
29
30
 
30
31
  ## Links
31
32
 
32
33
  - Only a `decision` branches: a `step` has at most 1 outgoing link, an `end` none.
33
34
  - `{ "from", "to" }`; a link leaving a decision also needs a `label` (`yes`, `no`, `none`, `cli`). A decision has at least 2 outgoing links. Loops back to an earlier step are allowed.
34
- - A link is planned when either end is `planned`, or it sets `"planned": true` (a plan adds a new branch between existing steps).
35
+ - A link is planned when either end is `planned`, or it sets `"planned": true` (a plan adds a new branch between existing steps, or a new link into a step it alters).
36
+ - In a plan, keep every link that exists now. One the plan drops between steps that stay sets `"removed": true` (with its anchor, if it leaves a decision); links to a `removed` step are removed without it. A step's shape (step, decision, end) follows the flow after the plan.
37
+ - A plan that removes something or alters an existing step (a `planned` step with a `source`) is drawn in the HTML as **Now** and **After plan** side by side.
35
38
 
36
39
  ## Anchors
37
40
 
@@ -40,6 +43,7 @@ An invented branch is the worst failure: it destroys the user's trust in the too
40
43
  - Anchors are read from the working tree. For a commit or branch that isn't checked out, render with `--at '<sha or branch>'` so they are read from that commit instead; otherwise lines that changed since won't resolve.
41
44
  - Required on every non-planned step and every non-planned link leaving a decision, each with its own anchor (a branch never inherits the decision's). Planned steps and links need none.
42
45
  - `render` checks every anchor against the files. A broken anchor fails the render: reread the file and fix the line, never drop the anchor or mark the step `planned` to get past it.
46
+ - Rendered with `--git`, `--since` or `--commit`, a summary's `new` or `changed` step whose file isn't in the diff gets a `✗` line (a warning; `--strict` exits 1).
43
47
  - Read the code you draw: flows have no context mode, and every anchor must be a line you actually saw.
44
48
 
45
49
  ## Rules and gaps
@@ -113,4 +117,4 @@ A plan to reject revoked invites in that endpoint: the steps above become `exist
113
117
  { "id": "403", "label": "403 invite revoked", "status": "planned" }
114
118
  ```
115
119
 
116
- Links: `expired → revoked` (`no`) replaces `expired → member`; add `revoked → 403` (`yes`) and `revoked → member` (`no`). All three are planned because `revoked` is.
120
+ Links: `expired → revoked` (`no`) replaces `expired → member`, so keep `expired → member` with `"removed": true` (and its anchor); add `revoked → 403` (`yes`) and `revoked → member` (`no`). The three new ones are planned because `revoked` is. The HTML shows today's flow next to the one after the plan.
@@ -46,12 +46,21 @@ Rules:
46
46
  - `kind`: table, enum, model, service, endpoint, component, file, config, other. Defaults to `file` when `path` is set, so a plain file node needs only `path`.
47
47
  - `layer`: free text, one per area: `database`, `backend`, `frontend`, `config`, `ci`. Nodes in a layer are drawn together, so keep the set small and consistent.
48
48
  - `summary`: one short line, what it is (not what changed).
49
- - `fields`: for tables, models and enums: **every** field you read, not only the changed ones. Mark changes with `change` (added, removed, modified); leave unchanged fields unmarked. In `short` mode only fields you actually read; in a plan, the fields you are committing to build are always listed (they are the plan).
49
+ - `fields`: for tables, models and enums: **every** field you read, not only the changed ones. Mark changes with `change` (added, removed, modified); leave unchanged fields unmarked. On a `modified` field, `was` is the old type when the type changes (`"type": "enum", "was": "text"`). In `short` mode only fields you actually read; in a plan, the fields you are committing to build are always listed (they are the plan).
50
+ - `match` (optional, needs `path`): a distinctive piece of one line in that file, copied from the diff, like a flow anchor. It must be on exactly one line. The HTML shows the line in the node's panel; the terminal doesn't.
50
51
  - `fieldsComplete`: required on every node with `fields`.
51
52
  - `true`: you read the whole definition (model, table or enum) and listed every field.
52
53
  - `false`: you list only what you saw, such as the changed columns in a migration. The map then says only some fields are shown.
53
54
  - In `full` context, open the definition so you can list every field and set `true`.
54
55
 
56
+ ## What `render` checks
57
+
58
+ Warnings, not failures (`--strict` makes them exit 1). Each mismatch is named in a `✗` line at the top of the output.
59
+
60
+ - **File exists:** every node with a `path`, except a summary's `removed` node (a class deleted from a file that stays) and a plan's `new` node (not built yet). A folder counts.
61
+ - **In the diff:** in a summary rendered with `--git`, `--since` or `--commit`, every `new`, `changed` or `removed` node's file. `context` and `config` nodes are not checked against the diff.
62
+ - **`match`:** found on exactly one line, when the file must exist.
63
+
55
64
  ## Edges
56
65
 
57
66
  ```json
@@ -62,6 +71,7 @@ Rules:
62
71
  - `label`: the column, method or key that makes the link (`team_id`, `list_projects()`, `reads DEFAULT_CURRENCY`). Short.
63
72
  - `kind`: fk, calls, imports, reads, writes, renders, configures, other. Use `writes` for a migration that creates or alters a table, and `other` for a model's `maps` edge to its table.
64
73
  - Only edges you saw in code, or (in a plan) ones you are committing to build.
74
+ - In a plan, `change` marks a link that moves between nodes existing before and after: `"added"` for one the plan builds, `"removed"` for one it drops. Leave it out on edges to a `new` or `removed` node; their status already says it. The HTML then shows the plan as Now and After side by side.
65
75
 
66
76
  ## gaps vs omitted vs your prose
67
77