@nightloom/isy 1.0.4 → 1.0.6-next.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.
Files changed (114) hide show
  1. package/README.md +18 -2
  2. package/dist/agents/claude.js +3 -2
  3. package/dist/agents/claude.js.map +1 -1
  4. package/dist/agents/codex.js +14 -5
  5. package/dist/agents/codex.js.map +1 -1
  6. package/dist/agents/index.d.ts +14 -10
  7. package/dist/agents/index.js +65 -15
  8. package/dist/agents/index.js.map +1 -1
  9. package/dist/agents/kimi.js +26 -8
  10. package/dist/agents/kimi.js.map +1 -1
  11. package/dist/agents/types.d.ts +12 -3
  12. package/dist/api.d.ts +1 -0
  13. package/dist/api.js +1 -1
  14. package/dist/api.js.map +1 -1
  15. package/dist/commands/commit.d.ts +6 -0
  16. package/dist/commands/commit.js +326 -16
  17. package/dist/commands/commit.js.map +1 -1
  18. package/dist/commands/health.js +1 -1
  19. package/dist/commands/health.js.map +1 -1
  20. package/dist/commands/init.js +40 -9
  21. package/dist/commands/init.js.map +1 -1
  22. package/dist/commands/status.d.ts +2 -0
  23. package/dist/commands/status.js +7 -4
  24. package/dist/commands/status.js.map +1 -1
  25. package/dist/commands/upload.d.ts +8 -1
  26. package/dist/commands/upload.js +65 -48
  27. package/dist/commands/upload.js.map +1 -1
  28. package/dist/detectors.d.ts +32 -0
  29. package/dist/detectors.js +279 -72
  30. package/dist/detectors.js.map +1 -1
  31. package/dist/git.d.ts +52 -0
  32. package/dist/git.js +166 -9
  33. package/dist/git.js.map +1 -1
  34. package/dist/githook.d.ts +18 -7
  35. package/dist/githook.js +147 -17
  36. package/dist/githook.js.map +1 -1
  37. package/dist/hook.d.ts +22 -2
  38. package/dist/hook.js +28 -3
  39. package/dist/hook.js.map +1 -1
  40. package/dist/index.js +23 -7
  41. package/dist/index.js.map +1 -1
  42. package/dist/mask-paths.d.ts +4 -3
  43. package/dist/mask-paths.js +4 -3
  44. package/dist/mask-paths.js.map +1 -1
  45. package/dist/parser.d.ts +58 -9
  46. package/dist/parser.js +337 -58
  47. package/dist/parser.js.map +1 -1
  48. package/dist/paths.d.ts +19 -1
  49. package/dist/paths.js +28 -3
  50. package/dist/paths.js.map +1 -1
  51. package/dist/redact.d.ts +2 -0
  52. package/dist/redact.js +987 -95
  53. package/dist/redact.js.map +1 -1
  54. package/dist/stage0.js +27 -8
  55. package/dist/stage0.js.map +1 -1
  56. package/dist/state.d.ts +15 -0
  57. package/dist/state.js +8 -0
  58. package/dist/state.js.map +1 -1
  59. package/dist/test/check.test.js +1 -1
  60. package/dist/test/check.test.js.map +1 -1
  61. package/dist/test/cli.test.js +11 -1
  62. package/dist/test/cli.test.js.map +1 -1
  63. package/dist/test/codex.test.js +27 -4
  64. package/dist/test/codex.test.js.map +1 -1
  65. package/dist/test/commit.test.js +1466 -6
  66. package/dist/test/commit.test.js.map +1 -1
  67. package/dist/test/e2e-harness.test.d.ts +1 -0
  68. package/dist/test/e2e-harness.test.js +53 -0
  69. package/dist/test/e2e-harness.test.js.map +1 -0
  70. package/dist/test/git.test.js +72 -2
  71. package/dist/test/git.test.js.map +1 -1
  72. package/dist/test/hook.test.js +138 -3
  73. package/dist/test/hook.test.js.map +1 -1
  74. package/dist/test/init.test.js +61 -2
  75. package/dist/test/init.test.js.map +1 -1
  76. package/dist/test/kimi-config.test.js +27 -5
  77. package/dist/test/kimi-config.test.js.map +1 -1
  78. package/dist/test/kimi-hook.test.js +1 -1
  79. package/dist/test/kimi-hook.test.js.map +1 -1
  80. package/dist/test/kimi-listing.test.js +42 -2
  81. package/dist/test/kimi-listing.test.js.map +1 -1
  82. package/dist/test/kimi.test.js +26 -2
  83. package/dist/test/kimi.test.js.map +1 -1
  84. package/dist/test/parser.test.js +527 -1
  85. package/dist/test/parser.test.js.map +1 -1
  86. package/dist/test/redact.test.js +2472 -14
  87. package/dist/test/redact.test.js.map +1 -1
  88. package/dist/test/stage0.test.js +617 -1
  89. package/dist/test/stage0.test.js.map +1 -1
  90. package/dist/test/sweep.test.js +110 -7
  91. package/dist/test/sweep.test.js.map +1 -1
  92. package/package.json +1 -1
  93. package/src/agents/claude.ts +3 -2
  94. package/src/agents/codex.ts +14 -5
  95. package/src/agents/index.ts +71 -16
  96. package/src/agents/kimi.ts +28 -8
  97. package/src/agents/types.ts +12 -3
  98. package/src/api.ts +4 -2
  99. package/src/commands/commit.ts +354 -18
  100. package/src/commands/health.ts +1 -1
  101. package/src/commands/init.ts +45 -10
  102. package/src/commands/status.ts +9 -4
  103. package/src/commands/upload.ts +73 -63
  104. package/src/detectors.ts +284 -75
  105. package/src/git.ts +175 -9
  106. package/src/githook.ts +151 -19
  107. package/src/hook.ts +30 -3
  108. package/src/index.ts +25 -7
  109. package/src/mask-paths.ts +5 -4
  110. package/src/parser.ts +355 -51
  111. package/src/paths.ts +30 -3
  112. package/src/redact.ts +991 -98
  113. package/src/stage0.ts +28 -8
  114. package/src/state.ts +18 -0
package/src/stage0.ts CHANGED
@@ -48,27 +48,47 @@ function order(a: Candidate, b: Candidate): number {
48
48
  * script — has nothing to say to a pull request. Masking decides it the way the
49
49
  * upload does: under the session's directory a path turns relative, under the
50
50
  * home it turns `~/…`, and only what stays absolute lies outside both. The
51
- * server reads transcripts already masked, `cwd` included (it reads `.`), so
52
- * there the paths are judged as they are.
51
+ * server reads transcripts already masked, `cwd` included (it reads `.` or a
52
+ * subdirectory), so there the paths are judged as they are.
53
53
  *
54
- * ponytail: a repository outside the home, with the session started in one of
55
- * its subdirectories, loses findings on sibling directories; the git root
56
- * recorded at upload is the way up.
54
+ * ponytail: a transcript masked with no repository to root at — by `isy
55
+ * analyze`, or by a client older than that rooting — from a session started in
56
+ * a subdirectory of a repository outside the home, loses findings on sibling
57
+ * directories. Pass `git.ts:maskRootsFor` to `isy analyze` if that shows up.
57
58
  */
58
59
  function inTree(candidate: Candidate, cwd: string | undefined): boolean {
59
60
  if (candidate.filePath === undefined || cwd === undefined) return true;
60
61
  return !looksAbsolute(maskPath(candidate.filePath, looksAbsolute(cwd) ? { cwd } : {}));
61
62
  }
62
63
 
64
+ /**
65
+ * What stage 0 may hold up to each other, past which it finds nothing. Its detectors
66
+ * take each edit to each other edit, call, file read and record, which is seconds
67
+ * here and hours at what 50 MB can hold, on the thread that serves requests. Length
68
+ * alone costs nothing: the largest real session, with its subagents, has 100 million
69
+ * pairs, and the next has 36 million from 20 thousand calls and 72 file edits.
70
+ *
71
+ * ponytail: the session goes on with no findings. Make the detectors linear if real
72
+ * sessions come near this.
73
+ */
74
+ const MOST_PAIRS = 500_000_000;
75
+
76
+ function tooManyPairs(session: ParsedSession): boolean {
77
+ // An edit call that records no edit is still looked up against what was read.
78
+ let edits = session.meta.editToolUses;
79
+ for (const recorded of session.fileEdits.values()) edits += recorded.length;
80
+ return edits * (edits + session.toolUses.length + session.filesRead.size + session.records.length) > MOST_PAIRS;
81
+ }
82
+
63
83
  export function runStage0(session: ParsedSession): Stage0Result {
64
84
  const thinkingBlocks = session.meta.thinkingBlocks;
65
85
  const reason = eligibility(session);
66
86
 
67
- if (reason) {
87
+ if (reason || tooManyPairs(session)) {
68
88
  return {
69
89
  sessionId: session.sessionId,
70
- eligible: false,
71
- reason,
90
+ eligible: reason === undefined,
91
+ ...(reason && { reason }),
72
92
  thinkingBlocks,
73
93
  knownGapReachable: thinkingBlocks > 0,
74
94
  candidates: [],
package/src/state.ts CHANGED
@@ -47,6 +47,15 @@ export interface SessionState {
47
47
  shown?: string[];
48
48
  /** Record count at each commit, oldest first: maps a record index to a commit. */
49
49
  commits?: CommitMark[];
50
+ /**
51
+ * The branch this session belongs to, for telling its commits from someone
52
+ * else's: the one its transcript names at its first upload, then where its
53
+ * latest mark landed. The checkout only stands in where the transcript names
54
+ * none, as with Codex and Kimi: an upload runs from wherever a push was made.
55
+ * Not simply the last branch it was seen on, because a resume that only reads
56
+ * moves nothing.
57
+ */
58
+ branch?: string;
50
59
  /** Last write to this entry, for pruning. */
51
60
  touchedMs?: number;
52
61
  }
@@ -197,6 +206,15 @@ function keyWithIndex(candidate: Candidate): string {
197
206
  ].join("\x00");
198
207
  }
199
208
 
209
+ /**
210
+ * The first of these that names a branch, for `SessionState.branch`. A detached
211
+ * HEAD names none: stored, it read as no branch known (`commit.ts:isItsCommit`),
212
+ * and every commit made anywhere after it passed as the session's.
213
+ */
214
+ export function namedBranch(...candidates: (string | undefined)[]): string | undefined {
215
+ return candidates.find((name) => name !== undefined && name !== "HEAD");
216
+ }
217
+
200
218
  /** Candidates this session has not printed before. */
201
219
  export function unseen(state: SessionState, candidates: readonly Candidate[]): Candidate[] {
202
220
  const shown = new Set(state.shown ?? []);