Skip to content

Commit e09a45e

Browse files
context: a tree with every file at its root is scoped to the root, not refused (#1345) (#1346)
The scope menu is built from the directories above the indexed files, so a repository whose files sit at its root had nothing to offer, and context refused with an empty list of suggestions. The root is the one scope such a tree has: context now uses it and says so, the way a single-package tree is handled.
1 parent b587523 commit e09a45e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎plugins/axiomcode/skills/axiomcode/scripts/axiomcode-context‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def main(argv):
419419
# does not filter. It does not weight either: boosting seeds inside it and penalising files outside
420420
# it was swept over 57 real commits and was worth at most 0.012 recall@10 against not doing it, which
421421
# is noise at that sample size. The menu is worth printing for the reader; it is not worth ranking on.
422-
rank = rank_dirs(g, scope_terms(g, task)) if not scopes else None
422+
rank = rank_dirs(g, scope_terms(g, task)) if not scopes else None; flat = False
423423
if not scopes:
424424
# One candidate is not a choice: take it and SAY SO, rather than refusing and being handed back
425425
# the only path there was. This is NOT the offered-scope case above, so it is not marked
@@ -430,6 +430,11 @@ def main(argv):
430430
if sole:
431431
scopes = [sole]
432432
print(f"scope: {sole} (the only package this graph indexes; --in overrides)\n")
433+
elif g.sym and not dirs_with_counts(g):
434+
# every indexed file sits at the root, so the root is the one scope there is, and it narrows nothing.
435+
# Refusing here offered an empty menu: a correction the reader could not act on (#1345)
436+
flat = True
437+
print("scope: the repository root (every indexed file sits there; --in overrides)\n")
433438
elif rank:
434439
# Several candidates, and a caller holding an issue and no symbol — which is the caller this
435440
# verb was written for, and by construction the one who cannot name the scope. Refusing here
@@ -452,7 +457,7 @@ def main(argv):
452457
+ ("…" if n > 4 else "") + ")")
453458
print(" no --in was given, so NOTHING below is narrowed to it — "
454459
"pass --in <path> to narrow.\n")
455-
bad = require_scope(g, scopes, terms, rank=rank, flag=' --in-offered')
460+
bad = None if flat else require_scope(g, scopes, terms, rank=rank, flag=' --in-offered')
456461
if bad is not None: return bad
457462

458463
# a symbol is kept when it is under ANY of the scopes -- the union, because the caller naming two roots

0 commit comments

Comments
 (0)