kushi-agents 5.9.5 → 5.9.7

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/bin/cli.mjs CHANGED
@@ -5,6 +5,62 @@ import { runMultiHost } from '../src/multi-host.mjs';
5
5
 
6
6
  const args = process.argv.slice(2);
7
7
 
8
+ // ── verb aliases (v5.9.6+) ──────────────────────────────────────────────────
9
+ // Natural-language synonyms for the canonical verbs. Keeps `kushi update HCA`
10
+ // / `kushi pull HCA` / `kushi sync HCA` / etc. from confusing humans + agents.
11
+ const VERB_ALIASES = {
12
+ // refresh-equivalents
13
+ 'update': 'refresh',
14
+ 'pull': 'refresh',
15
+ 'sync': 'refresh',
16
+ 'regenerate': 'refresh',
17
+ 'refresh-runner': 'refresh', // back-compat with v5.9.0–v5.9.5 internal name
18
+ // bootstrap-equivalents
19
+ 'init': 'bootstrap',
20
+ 'new': 'bootstrap',
21
+ 'bootstrap-runner': 'bootstrap', // back-compat
22
+ };
23
+ if (args.length > 0 && VERB_ALIASES[args[0]]) {
24
+ args[0] = VERB_ALIASES[args[0]];
25
+ }
26
+
27
+ // ── alias resolution (v5.9.7+) ──────────────────────────────────────────────
28
+ // Mirrors `instructions/identity-resolution.instructions.md`: read alias from
29
+ // <cwd>/.kushi/config/user/project-evidence.yml, with KUSHI_ALIAS env override.
30
+ // No silent git-email derivation, no Graph fallback — same rules as chat.
31
+ async function resolveAlias() {
32
+ if (process.env.KUSHI_ALIAS && process.env.KUSHI_ALIAS.trim()) {
33
+ return { alias: process.env.KUSHI_ALIAS.trim(), source: 'env' };
34
+ }
35
+ const fs = await import('node:fs');
36
+ const path = await import('node:path');
37
+ const cfgPath = path.resolve(process.cwd(), '.kushi', 'config', 'user', 'project-evidence.yml');
38
+ if (!fs.existsSync(cfgPath)) return { alias: null, source: 'missing-config' };
39
+ try {
40
+ const txt = fs.readFileSync(cfgPath, 'utf-8');
41
+ const m = txt.match(/^\s*alias:\s*([^\s#]+)/m);
42
+ if (!m) return { alias: null, source: 'no-alias-key' };
43
+ const v = m[1].trim();
44
+ if (!v || v === '<auto>' || v.startsWith('<') || v === 'your-alias') {
45
+ return { alias: null, source: 'placeholder' };
46
+ }
47
+ return { alias: v, source: 'project-evidence.yml' };
48
+ } catch {
49
+ return { alias: null, source: 'read-error' };
50
+ }
51
+ }
52
+
53
+ function printAliasError(verb, project) {
54
+ console.error(`\n Couldn't resolve your alias — needed for the deterministic runner.`);
55
+ console.error(`\n The runner writes evidence into Evidence/<alias>/, so it must know who you are.`);
56
+ console.error(`\n Fix one of these (any works):`);
57
+ console.error(` • cd to a workspace that already has .kushi/ installed (run from there)`);
58
+ console.error(` • Run \`kushi setup\` to seed your identity in this workspace`);
59
+ console.error(` • Set the env var: $env:KUSHI_ALIAS = '<your-alias>' (PowerShell)`);
60
+ console.error(` export KUSHI_ALIAS=<your-alias> (bash)`);
61
+ console.error(` • Run from VS Code Copilot Chat instead: @Kushi ${verb} ${project}\n`);
62
+ }
63
+
8
64
  // ── bare invocation ──────────────────────────────────────────────────────────
9
65
  // Two bins share this cli (via thin wrappers in bin/kushi.mjs and
10
66
  // bin/kushi-agents.mjs that set KUSHI_BIN_NAME). Behavior diverges on no-args:
@@ -242,43 +298,56 @@ Usage: kushi [COMMAND] [ARGS...]
242
298
 
243
299
  Kushi v${version} — multi-source M365 project evidence + Q&A agent.
244
300
 
245
- Common Commands:
246
- bootstrap <project> First-time setup for a project (full pull)
247
- refresh <project> Incremental refresh + rebuild State/
248
- ask <project> <question> Cited Q&A over Evidence/ (auto-routes; --file-back to save)
249
- status <project> Show run-log for a project
250
- wiki Resolve + scaffold + open the global wiki (one-shot)
251
- doctor Aggregated health check (env, drift, evals, etc.)
252
-
253
- Project Commands:
254
- state <project> Re-render State/ from existing Evidence
255
- references <project> Refresh shared references pool from Evidence URLs
256
- consolidate <project> Merge per-user evidence into _Consolidated
257
- lint <project> Run wiki-lint checks on State/
258
- promote <project> <page> Move a project page into the global wiki (with redaction)
259
- setup [<project>] Run the onboarding wizard / fill missing config
260
-
261
- Global Wiki Commands:
262
- global init Scaffold ~/.kushi-global/State/ (or KUSHI_GLOBAL_ROOT)
263
- global status Page counts + freshness
264
- global ask <question> Search the global wiki specifically
265
- global lint Privacy + freshness scan
266
- global show-root Show the 4-tier resolution chain
267
- global set-root <path> Persist globalRoot (--scope workspace|home)
268
- global migrate <new-path> Copy State/ to a new root + re-persist
269
-
270
- Lifecycle Commands:
271
- upgrade npm i -g kushi-agents@latest then re-seed assets in cwd
272
- uninstall [--keep-config] Remove <cwd>/.kushi/ (preserves Evidence/, State/)
273
-
274
- Authoring Commands:
275
- create-skill <name> Scaffold a new plugin/skills/<name>/ tree
276
- check-skill <name|--all> Lint a skill (or all skills) against the blueprint
277
- optimize-description <s> Rewrite a skill's description per optimizer rules
278
- review-evals <skill> Render an HTML eval-review viewer
279
- explain <topic> Explain a kushi concept (read-only)
280
- remember <rule> Persist a project convention to CLAUDE.md
281
- hooks list|test <project> Inspect or fire hook events
301
+ CLI Commands (run from your shell):
302
+
303
+ Project pipeline (deterministic runners):
304
+ bootstrap <project> First-time pull for a project (alias: init, new)
305
+ refresh <project> Incremental refresh (alias: update, pull, sync, regenerate)
306
+ state <project> Re-render State/ from existing Evidence
307
+ references <project> Refresh shared references pool from Evidence URLs
308
+ discover <project> Discover M365 hints (sections, chats) for a project
309
+
310
+ Project lifecycle:
311
+ setup [<project>] Run the onboarding wizard / fill missing config
312
+ promote <project> <page> Move a project page into the global wiki (with redaction)
313
+ lint <project> Run wiki-lint checks on State/
314
+
315
+ Global wiki:
316
+ wiki Resolve + scaffold + open the global wiki (one-shot)
317
+ global init|status|ask|lint|show-root|set-root|migrate
318
+
319
+ Install / lifecycle:
320
+ upgrade npm i -g kushi-agents@latest then re-seed assets in cwd
321
+ uninstall [--keep-config] Remove <cwd>/.kushi/ (preserves Evidence/, State/)
322
+ doctor Aggregated health check (env, drift, evals, etc.)
323
+ --version | -v Print kushi version and exit
324
+ help | --help Show this help
325
+
326
+ Skill authoring (full profile):
327
+ create-skill <name> Scaffold a new plugin/skills/<name>/ tree
328
+ check-skill <name> Lint a skill against the blueprint
329
+ optimize-description <s> Rewrite a skill's description per optimizer rules
330
+ review-evals <skill> Render an HTML eval-review viewer
331
+ explain <topic> Explain a kushi concept (read-only)
332
+ remember <rule> Persist a project convention to CLAUDE.md
333
+ hooks list|test <project> Inspect or fire hook events
334
+
335
+ Chat Verbs (run from VS Code Copilot Chat with @Kushi <verb>):
336
+ @Kushi ask <project> <q> Cited Q&A over Evidence/ (auto-routes)
337
+ @Kushi status <project> Run-log + freshness summary
338
+ @Kushi consolidate <project> Merge per-user evidence into _Consolidated
339
+ @Kushi tour <project> [--top N] Auto-generated week-in-review walkthrough
340
+ @Kushi dashboard <project> Status dashboard
341
+ @Kushi aggregate <project> Multi-week aggregate
342
+ @Kushi fde-intake | fde-report | fde-triage <project>
343
+ @Kushi link-entities <project> Cross-link entities across projects
344
+ @Kushi teach <topic> Teach kushi a doctrine fact
345
+ @Kushi explain <topic> Recall a taught fact
346
+ @Kushi vertex-link | emit-vertex <project>
347
+
348
+ These verbs need the LLM-driven orchestrator that only Copilot Chat
349
+ provides (interactive clarifications + cited narrative). Typing them in
350
+ the shell prints a redirect to the chat path.
282
351
 
283
352
  Install (run via npx — first-time / host install):
284
353
  npx kushi-agents --clawpilot Install to ~/.copilot/m-skills/kushi/
@@ -300,10 +369,12 @@ In VS Code Chat the prefix is "@Kushi". In Clawpilot just say "kushi <verb>".
300
369
  }
301
370
 
302
371
 
303
- // ── state / refresh / bootstrap verbs (v5.9.0+) ─────────────────────────────
304
- // Thin shells that exec the deterministic runners. Keeps `kushi state HCA` etc.
305
- // runnable from the global bin without users having to know the runner paths.
306
- if (args.length > 0 && ['state', 'refresh-runner', 'bootstrap-runner', 'discover', 'references'].includes(args[0])) {
372
+ // ── deterministic runner verbs (v5.9.0+, renamed in v5.9.6) ─────────────────
373
+ // Thin shells that exec the deterministic runners. `kushi refresh HCA` /
374
+ // `kushi bootstrap HCA` / `kushi state HCA` etc. all run from the global bin
375
+ // without users having to know the runner paths. Chat orchestrator
376
+ // `@Kushi refresh` adds narrative + interactive clarification on top.
377
+ if (args.length > 0 && ['state', 'refresh', 'bootstrap', 'discover', 'references'].includes(args[0])) {
307
378
  const verb = args[0];
308
379
  const project = args[1];
309
380
  if (!project) {
@@ -315,15 +386,29 @@ if (args.length > 0 && ['state', 'refresh-runner', 'bootstrap-runner', 'discover
315
386
  const urlMod = await import('node:url');
316
387
  const here = pathMod.dirname(urlMod.fileURLToPath(import.meta.url));
317
388
  const runnerMap = {
318
- state: 'pull-state.mjs',
389
+ state: 'pull-state.mjs',
319
390
  references: 'pull-references.mjs',
320
- discover: 'discover.mjs',
321
- 'refresh-runner': 'refresh.mjs',
322
- 'bootstrap-runner': 'bootstrap.mjs',
391
+ discover: 'discover.mjs',
392
+ refresh: 'refresh.mjs',
393
+ bootstrap: 'bootstrap.mjs',
323
394
  };
324
395
  const runner = pathMod.resolve(here, '..', 'plugin', 'runners', runnerMap[verb]);
325
396
  const passthrough = args.slice(2);
326
- const r = spawnSync(process.execPath, [runner, '--project', project, ...passthrough], { stdio: 'inherit' });
397
+ // v5.9.7: resolve alias the same way chat does, unless caller already passed --alias
398
+ const hasAliasFlag = passthrough.some((a, i) => a === '--alias' && passthrough[i + 1]);
399
+ let aliasArgs = [];
400
+ if (!hasAliasFlag) {
401
+ const { alias, source } = await resolveAlias();
402
+ if (!alias) {
403
+ printAliasError(verb, project);
404
+ process.exit(1);
405
+ }
406
+ aliasArgs = ['--alias', alias];
407
+ if (source === 'env') {
408
+ process.stderr.write(`\n Using alias='${alias}' from KUSHI_ALIAS env var.\n`);
409
+ }
410
+ }
411
+ const r = spawnSync(process.execPath, [runner, '--project', project, ...aliasArgs, ...passthrough], { stdio: 'inherit' });
327
412
  process.exit(r.status ?? 1);
328
413
  }
329
414
 
@@ -409,10 +494,12 @@ if (args.length > 0 && args[0] === 'upgrade') {
409
494
  // These verbs are dispatched by Copilot Chat (`@Kushi <verb>`), not the CLI.
410
495
  // If a user types e.g. `kushi ask HCA "..."` in PowerShell, fall through to
411
496
  // installer used to silently run. Now we print a friendly redirect.
497
+ // v5.9.6: refresh/bootstrap removed — they now route to the deterministic
498
+ // runners directly (see runner-verbs block above).
412
499
  const CHAT_ONLY_VERBS = new Set([
413
- 'ask', 'bootstrap', 'refresh', 'status', 'consolidate', 'tour', 'dashboard',
500
+ 'ask', 'status', 'consolidate', 'tour', 'dashboard',
414
501
  'aggregate', 'fde-intake', 'fde-report', 'fde-triage', 'link-entities',
415
- 'migrate-files', 'pull', 'schema-evolve', 'teach', 'vertex-link',
502
+ 'migrate-files', 'schema-evolve', 'teach', 'vertex-link',
416
503
  'emit-vertex',
417
504
  ]);
418
505
  if (args.length > 0 && CHAT_ONLY_VERBS.has(args[0])) {
@@ -427,9 +514,11 @@ if (args.length > 0 && CHAT_ONLY_VERBS.has(args[0])) {
427
514
  In Clawpilot:
428
515
  kushi ${verb}${rest ? ' ' + rest : ' <project> [args]'}
429
516
 
430
- CLI verbs (run from PowerShell): kushi help, kushi wiki, kushi doctor,
431
- kushi upgrade, kushi uninstall, kushi setup,
432
- kushi state, kushi promote, kushi global, kushi lint
517
+ CLI verbs (deterministic, run from PowerShell):
518
+ kushi bootstrap | refresh | state | references | discover <project>
519
+ kushi promote | lint <project>
520
+ kushi wiki | global | doctor | upgrade | uninstall | setup
521
+ kushi help | --version
433
522
  See: kushi help
434
523
  `);
435
524
  process.exit(2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kushi-agents",
3
- "version": "5.9.5",
3
+ "version": "5.9.7",
4
4
  "description": "Install Kushi — multi-source project evidence agent with Comprehensive Structured Capture (CSC) into weekly-only files across Email, Teams, OneNote, Loop, SharePoint, Meetings, CRM, ADO. Meetings retain a sibling verbatim/ audit folder. WorkIQ-only for M365 sources (Graph / m365_* FORBIDDEN as fallbacks; user-paste is first-class). Host-agnostic.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -103,6 +103,9 @@ When a user message arrives:
103
103
 
104
104
  1. Identify the **verb** (setup / aggregate / bootstrap / refresh / state / consolidate / status / pull / **ask** / fde-intake / fde-report / fde-triage).
105
105
  - If the message starts with an explicit producer verb → use it.
106
+ - **Natural-language verb synonyms** auto-route to canonical verbs:
107
+ - "update <X>" / "pull <X>" / "sync <X>" / "regenerate <X>" / "do it all for <X>" / "weekly extract for <X>" / "bring <X> up to date" → `refresh <X>`
108
+ - "init <X>" / "new <X>" / "set up project evidence for <X>" / "add me to project <X>" / "add contributor to <X>" → `bootstrap <X>`
106
109
  - **setup** dispatches immediately on `setup`, `setup --reconfigure`, `verify workiq`, `who am I to kushi`, `fix my install`, `setup kushi`.
107
110
  - Else if the message contains a known project name AND a question shape (interrogative, "status of", "summarize", bare `<project> <topic>`) → `ask`.
108
111
  - Else → ask the user to clarify.