kairn-cli 1.12.0 → 1.13.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/dist/cli.js CHANGED
@@ -706,6 +706,16 @@ Use subagents for deep investigation to keep main context clean.
706
706
  - Do not create abstractions for one-time operations
707
707
  - Complete the task fully \u2014 don't gold-plate, but don't leave it half-done
708
708
  - Prefer editing existing files over creating new ones
709
+
710
+ ## First Turn Protocol
711
+
712
+ At the start of every session, before doing ANY work:
713
+ 1. Run \`pwd && ls -la && git status --short\` to orient yourself
714
+ 2. Check relevant runtimes (e.g. \`node --version\`, \`python3 --version\` \u2014 pick what fits this project)
715
+ 3. Read any task-tracking files (docs/SPRINT.md, docs/DECISIONS.md)
716
+ 4. Summarize what you see in 2-3 lines, then proceed
717
+
718
+ This saves 2-5 exploratory turns. Never ask "what files are here?" \u2014 look first.
709
719
  \`\`\`
710
720
 
711
721
  Do not add generic filler. Every line must be specific to the user's workflow.
@@ -727,6 +737,7 @@ Do not add generic filler. Every line must be specific to the user's workflow.
727
737
  13. A "Debugging" section in CLAUDE.md (2 lines: paste raw errors, use subagents)
728
738
  14. A "Git Workflow" section in CLAUDE.md (3 rules: small commits, conventional format, <200 lines PR)
729
739
  15. "Engineering Standards", "Tool Usage Policy", and "Code Philosophy" sections in CLAUDE.md
740
+ 16. A "First Turn Protocol" section in CLAUDE.md (orient before working: pwd, ls, git status, check relevant runtimes, read task files)
730
741
 
731
742
  ## Shell-Integrated Commands
732
743
 
@@ -1002,6 +1013,16 @@ Use subagents for deep investigation to keep main context clean.
1002
1013
  - Do not create abstractions for one-time operations
1003
1014
  - Complete the task fully \u2014 don't gold-plate, but don't leave it half-done
1004
1015
  - Prefer editing existing files over creating new ones
1016
+
1017
+ ## First Turn Protocol
1018
+
1019
+ At the start of every session, before doing ANY work:
1020
+ 1. Run \`pwd && ls -la && git status --short\` to orient yourself
1021
+ 2. Check relevant runtimes (e.g. \`node --version\`, \`python3 --version\` \u2014 pick what fits this project)
1022
+ 3. Read any task-tracking files (docs/SPRINT.md, docs/DECISIONS.md)
1023
+ 4. Summarize what you see in 2-3 lines, then proceed
1024
+
1025
+ This saves 2-5 exploratory turns. Never ask "what files are here?" \u2014 look first.
1005
1026
  \`\`\`
1006
1027
 
1007
1028
  Do not add generic filler. Every line must be specific to the user's workflow.
@@ -1023,6 +1044,7 @@ Do not add generic filler. Every line must be specific to the user's workflow.
1023
1044
  13. A "Debugging" section in CLAUDE.md (2 lines: paste raw errors, use subagents)
1024
1045
  14. A "Git Workflow" section in CLAUDE.md (3 rules: small commits, conventional format, <200 lines PR)
1025
1046
  15. "Engineering Standards", "Tool Usage Policy", and "Code Philosophy" sections in CLAUDE.md
1047
+ 16. A "First Turn Protocol" section in CLAUDE.md (orient before working: pwd, ls, git status, check relevant runtimes, read task files)
1026
1048
 
1027
1049
  ## Tool Selection Rules
1028
1050
 
@@ -1577,6 +1599,61 @@ ${agentList}
1577
1599
  Type \`/project:help\` in Claude Code for a quick reference.
1578
1600
  `;
1579
1601
  }
1602
+ var BOOTSTRAP_COMMAND = `# Environment Snapshot
1603
+
1604
+ Run this command at the start of any session to gather runtime context.
1605
+ This saves 2-5 exploratory turns.
1606
+
1607
+ 1. Run the following compound command and read the output:
1608
+ \`\`\`bash
1609
+ echo '=== WORKING DIRECTORY ===' && pwd && \\
1610
+ echo '=== PROJECT FILES ===' && ls -la && \\
1611
+ echo '=== GIT STATUS ===' && (git status --short 2>/dev/null || echo 'not a git repo') && \\
1612
+ echo '=== LANGUAGES ===' && \\
1613
+ (node --version 2>&1 || true) && \\
1614
+ (python3 --version 2>&1 || true) && \\
1615
+ (go version 2>&1 || true) && \\
1616
+ (rustc --version 2>&1 || true) && \\
1617
+ echo '=== PACKAGE MANAGERS ===' && \\
1618
+ (npm --version 2>&1 && echo "npm $(npm --version 2>&1)" || true) && \\
1619
+ (pip3 --version 2>&1 || true) && \\
1620
+ (cargo --version 2>&1 || true) && \\
1621
+ echo '=== ENVIRONMENT ===' && \\
1622
+ (cat .env 2>/dev/null | sed 's/=.*/=***/' || echo 'no .env file')
1623
+ \`\`\`
1624
+
1625
+ 2. Summarize the environment in 3-4 lines:
1626
+ - Runtime: [languages + versions found]
1627
+ - Project: [framework, key deps, file count]
1628
+ - State: [git branch, clean/dirty, .env present]
1629
+
1630
+ 3. Keep this summary in context for the rest of the session.`;
1631
+ function buildBootstrapHookCommand(spec) {
1632
+ const checks = [
1633
+ "echo '--- Environment Snapshot ---'",
1634
+ "pwd",
1635
+ "ls -la --color=never | head -20",
1636
+ "echo '---'",
1637
+ "git status --short 2>/dev/null || true",
1638
+ "echo '---'"
1639
+ ];
1640
+ const md = (spec.harness.claude_md ?? "").toLowerCase();
1641
+ if (md.includes("node") || md.includes("typescript") || md.includes("javascript") || md.includes("react") || md.includes("next")) {
1642
+ checks.push("node --version 2>&1 || true");
1643
+ checks.push("cat package.json 2>/dev/null | head -5 || true");
1644
+ }
1645
+ if (md.includes("python") || md.includes("django") || md.includes("flask") || md.includes("fastapi")) {
1646
+ checks.push("python3 --version 2>&1 || true");
1647
+ }
1648
+ if (md.includes("rust") || md.includes("cargo")) {
1649
+ checks.push("rustc --version 2>&1 || true");
1650
+ }
1651
+ if (md.includes("go ") || md.includes("golang")) {
1652
+ checks.push("go version 2>&1 || true");
1653
+ }
1654
+ checks.push("cat .env 2>/dev/null | sed 's/=.*/=***/' || true");
1655
+ return checks.join(" && ");
1656
+ }
1580
1657
  var LOOP_COMMAND_CODE = `# Development Loop
1581
1658
 
1582
1659
  Run an assisted development cycle for the next feature.
@@ -1750,6 +1827,9 @@ function applyAutonomyLevel(spec) {
1750
1827
  settings.hooks = hooks;
1751
1828
  }
1752
1829
  if (level >= 2) {
1830
+ if (!("bootstrap" in commands)) {
1831
+ commands.bootstrap = BOOTSTRAP_COMMAND;
1832
+ }
1753
1833
  if (!("loop" in commands)) {
1754
1834
  commands.loop = isResearchProject(spec) ? LOOP_COMMAND_RESEARCH : LOOP_COMMAND_CODE;
1755
1835
  }
@@ -1761,6 +1841,18 @@ function applyAutonomyLevel(spec) {
1761
1841
  if (!("auto" in commands)) {
1762
1842
  commands.auto = AUTO_COMMAND;
1763
1843
  }
1844
+ const hooks = settings.hooks ?? {};
1845
+ const sessionStart = hooks.SessionStart ?? [];
1846
+ const bootstrapHook = {
1847
+ matcher: "",
1848
+ hooks: [{
1849
+ type: "command",
1850
+ command: buildBootstrapHookCommand(spec)
1851
+ }]
1852
+ };
1853
+ sessionStart.push(bootstrapHook);
1854
+ hooks.SessionStart = sessionStart;
1855
+ settings.hooks = hooks;
1764
1856
  }
1765
1857
  if (level >= 4) {
1766
1858
  if (!("autopilot" in commands)) {