@rowan-hiro/inkan 0.2.0 → 0.2.2

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 CHANGED
@@ -203,10 +203,13 @@ seal is a fact; close with dispositions, then commit the record with the
203
203
  work and include the outcome trailer; re-anchor with `inkan status` after
204
204
  context loss and leave other sessions' outcomes alone; closed outcomes are
205
205
  final and commit references are informational when reading history.
206
- The block carries a protocol number. `init`
206
+ The block states policy only. It names the commands and what each call
207
+ must carry, and leaves flag-level syntax to `inkan help`, so a CLI change
208
+ does not bump the protocol. The block carries a protocol number. `init`
207
209
  upgrades a block it generated under an earlier protocol in place and refuses
208
210
  to overwrite a block that was edited by hand, so the policy lives in exactly
209
- one place. `--lang <tag>` sets the language agents should write outcome
211
+ one place. A block stamped with a protocol newer than the installed Inkan
212
+ is reported as such, with a prompt to upgrade the tool, not as a hand edit. `--lang <tag>` sets the language agents should write outcome
210
213
  prose in. `inkan init --claude` also creates `CLAUDE.md` as a symlink to
211
214
  `AGENTS.md`: Claude Code reads its own file name, and there is still one
212
215
  policy, not a copy.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowan-hiro/inkan",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Seal the authoritative outcome; keep a trustworthy record of the process.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/api.js CHANGED
@@ -523,7 +523,28 @@ Outcome log: \`.inkan/outcomes/<id>.jsonl\`, one append-only file per outcome. C
523
523
  ${END_MARKER}`;
524
524
  }
525
525
 
526
- const PROTOCOL_VERSION = 6;
526
+ function protocolBlockV7(lang) {
527
+ return `${START_MARKER}
528
+ <!-- inkan-protocol: 7 -->
529
+ <!-- inkan-lang: ${lang} -->
530
+
531
+ ## Agent protocol: sealed outcomes
532
+
533
+ This repository uses Inkan (\`inkan\`, alias \`ink\`). Inkan keeps a trustworthy record of what the work was meant to deliver and what was declared at close. It does not inspect commits, run tests, or judge the result; the repository's own checks do that. Write outcome prose in ${lang}. This block states the policy; \`inkan help\` gives the command syntax.
534
+
535
+ 1. **Seal before durable changes.** Before changing code, configuration, documentation, or dependencies, run \`inkan status\`; if it shows an open outcome that is not your work, follow rule 4 first. Then run \`inkan begin\` with the outcome, one observable acceptance criterion at a time, and every decision record the work is bound by. File the outcome by lane only when the repository already files outcomes by lane.
536
+ 2. **The seal is a fact.** Deliver what it says. If circumstances change, do not reinterpret it: run \`inkan amend\` with the reason and the added or withdrawn criteria. The original text stays. Never question why the outcome was sealed the way it was at the time.
537
+ 3. **Close with dispositions, then commit.** Run \`inkan end\` with a disposition, met or unmet, for every live criterion and a note on what happened. Commit the outcome record with the work. Include the printed \`Inkan-Outcome: <id>\` trailer in the final paragraph of the landing commit message, beside any other trailers with no blank line between them. Never report success without closing the outcome.
538
+ 4. **Re-anchor after context loss.** Run \`inkan status\` and \`inkan log -n 3\`. An open outcome that is the work you were asked to do is your task: continue it, or close it with a note. An open outcome that is not your work belongs to another session: leave it alone. Never close, amend, or abandon an outcome you did not work on, and do not judge why it is still open. Before beginning your own outcome beside it, stop and tell the person it is there, and ask whether your work should run in its own git worktree, because separate worktrees keep each session's edits apart.
539
+ 5. **Closed outcomes are final.** Reviewing the log is reading, not re-checking. Never re-verify, re-attest, or re-close a closed outcome. If a past declaration now looks wrong, that is a new outcome with its own seal. When reading history, use commit trailers only as references. Missing trailers or unavailable referenced records are missing information, not failed outcomes or a reason to verify delivery or repair history.
540
+
541
+ Decision records live in \`.inkan/decisions/\`. Their Context and Decision sections record the scenario at the time and are never edited. To challenge one, run \`inkan decision update\` with the new status and the reason, or add a new record that supersedes it.
542
+
543
+ Outcome log: \`.inkan/outcomes/<id>.jsonl\`, one append-only file per outcome. Commit \`.inkan/\` with the code. Do not edit these files by hand.
544
+ ${END_MARKER}`;
545
+ }
546
+
547
+ const PROTOCOL_VERSION = 7;
527
548
 
528
549
  /**
529
550
  * The managed block for `lang` at protocol `version`, current by default.
@@ -537,6 +558,7 @@ export function protocolBlock(lang, version = PROTOCOL_VERSION) {
537
558
  if (version === 4) return protocolBlockV4(lang);
538
559
  if (version === 5) return protocolBlockV5(lang);
539
560
  if (version === 6) return protocolBlockV6(lang);
561
+ if (version === 7) return protocolBlockV7(lang);
540
562
  throw new InkanError(`unknown protocol version ${version}`);
541
563
  }
542
564
 
@@ -629,6 +651,15 @@ function writeProtocol(dir, lang) {
629
651
  fs.writeFileSync(agentsFile, content, 'utf8');
630
652
  return { root: dir, agentsFile, changed: true };
631
653
  }
654
+ // A block stamped with a protocol this tool does not know yet was written
655
+ // by a newer Inkan, not by hand. Say so and leave it alone.
656
+ const stamped = found.text.match(/<!-- inkan-protocol: (\d+) -->/);
657
+ const foundVersion = stamped ? Number(stamped[1]) : 0;
658
+ if (foundVersion > PROTOCOL_VERSION) {
659
+ throw new InkanError(
660
+ `${AGENTS_FILENAME} inkan block is protocol ${foundVersion}; this Inkan knows up to ${PROTOCOL_VERSION}. Upgrade Inkan; refusing to overwrite it`,
661
+ );
662
+ }
632
663
  throw new InkanError(`${AGENTS_FILENAME} inkan block was edited by hand; refusing to overwrite it`);
633
664
  }
634
665
 
package/src/cli.js CHANGED
@@ -22,12 +22,20 @@ Commands:
22
22
  Create .inkan/ and write the agent protocol block into AGENTS.md.
23
23
  --claude also links CLAUDE.md to AGENTS.md.
24
24
  begin "<outcome>" [--accept <text>]... [--decision <id>]... [--lane <tag>]
25
- Seal a new outcome; prints its id.
25
+ Seal a new outcome; prints its id. Repeat --accept once per
26
+ observable criterion; they are numbered from 1 in that order.
27
+ Repeat --decision once per decision record the work is bound by.
28
+ Use --lane only where the repository already files outcomes by lane.
26
29
  amend --reason <text> [<addition>] [--accept <text>]... [--withdraw <n>]...
27
30
  [--decision <id>]... [<id>]
28
31
  Append an amendment to the open outcome; prints the new contract hash.
32
+ --reason is required. Added criteria continue the numbering;
33
+ --withdraw takes a criterion number. The original text is kept.
29
34
  end [<id>] [--met <n>]... [--unmet <n>]... [-s abandoned] --note <text>
30
- Record dispositions and close an outcome; print its commit reference.
35
+ Record dispositions and close an outcome; prints the Inkan-Outcome
36
+ trailer to put in the landing commit. Repeat --met or --unmet once
37
+ per live criterion number; every live criterion needs one. A value
38
+ may carry a note as "<n>: <text>". --note is required.
31
39
  status
32
40
  Print every open outcome.
33
41
  log [-n <count>] [--since <date>] [--grep <regex>] [--status <s>]