aiwcli 0.12.7 → 0.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.
Files changed (134) hide show
  1. package/dist/commands/clean.d.ts +7 -0
  2. package/dist/commands/clean.js +17 -8
  3. package/dist/commands/clear.d.ts +85 -0
  4. package/dist/commands/clear.js +455 -347
  5. package/dist/commands/init/index.d.ts +15 -0
  6. package/dist/commands/init/index.js +79 -38
  7. package/dist/lib/gitignore-manager.js +12 -13
  8. package/dist/lib/settings-hierarchy.d.ts +13 -1
  9. package/dist/lib/settings-hierarchy.js +1 -1
  10. package/dist/lib/template-linter.d.ts +4 -0
  11. package/dist/lib/template-linter.js +1 -1
  12. package/dist/lib/tty-detection.d.ts +1 -0
  13. package/dist/lib/tty-detection.js +1 -0
  14. package/dist/templates/CLAUDE.md +27 -0
  15. package/dist/templates/_shared/.claude/settings.json +7 -7
  16. package/dist/templates/_shared/.claude/{commands/handoff.md → skills/handoff/SKILL.md} +4 -3
  17. package/dist/templates/_shared/.claude/{commands/handoff-resume.md → skills/handoff-resume/SKILL.md} +3 -2
  18. package/dist/templates/_shared/.claude/skills/meta-plan/SKILL.md +43 -0
  19. package/dist/templates/_shared/.codex/workflows/handoff.md +1 -1
  20. package/dist/templates/_shared/.codex/workflows/meta-plan.md +347 -0
  21. package/dist/templates/_shared/.windsurf/workflows/handoff.md +1 -1
  22. package/dist/templates/_shared/.windsurf/workflows/meta-plan.md +347 -0
  23. package/dist/templates/_shared/hooks-ts/lint_after_edit.ts +59 -0
  24. package/dist/templates/_shared/hooks-ts/session_end.ts +11 -10
  25. package/dist/templates/_shared/hooks-ts/session_start.ts +15 -12
  26. package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +12 -12
  27. package/dist/templates/_shared/lib-ts/CLAUDE.md +3 -3
  28. package/dist/templates/_shared/lib-ts/base/constants.ts +324 -306
  29. package/dist/templates/_shared/lib-ts/base/hook-utils.ts +26 -7
  30. package/dist/templates/_shared/lib-ts/base/inference.ts +19 -19
  31. package/dist/templates/_shared/lib-ts/base/lint-dispatch.ts +287 -0
  32. package/dist/templates/_shared/lib-ts/base/state-io.ts +4 -3
  33. package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +3 -3
  34. package/dist/templates/_shared/lib-ts/context/CLAUDE.md +134 -0
  35. package/dist/templates/_shared/lib-ts/context/context-formatter.ts +16 -15
  36. package/dist/templates/_shared/lib-ts/context/context-selector.ts +16 -16
  37. package/dist/templates/_shared/lib-ts/context/context-store.ts +15 -14
  38. package/dist/templates/_shared/lib-ts/context/plan-manager.ts +2 -2
  39. package/dist/templates/_shared/scripts/resolve-run.ts +61 -0
  40. package/dist/templates/_shared/scripts/resolve_context.ts +1 -1
  41. package/dist/templates/_shared/scripts/status_line.ts +100 -94
  42. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/CLAUDE.md +433 -421
  43. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/document-generator.ts +5 -4
  44. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/handoff-reader.ts +2 -1
  45. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/resume_handoff.ts +6 -6
  46. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/save_handoff.ts +16 -17
  47. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff-resume.md +2 -2
  48. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff.md +3 -3
  49. package/dist/templates/_shared/skills/meta-plan/CLAUDE.md +44 -0
  50. package/dist/templates/_shared/skills/meta-plan/workflows/meta-plan.md +347 -0
  51. package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +1 -1
  52. package/dist/templates/cc-native/.claude/settings.json +86 -57
  53. package/dist/templates/cc-native/_cc-native/artifacts/CLAUDE.md +64 -0
  54. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/format.ts +599 -597
  55. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/index.ts +26 -26
  56. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/tracker.ts +107 -106
  57. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/write.ts +119 -118
  58. package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +237 -247
  59. package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +76 -74
  60. package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +76 -0
  61. package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +163 -156
  62. package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +15 -16
  63. package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +116 -116
  64. package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +3 -3
  65. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +16 -12
  66. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +2 -3
  67. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +31 -31
  68. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +7 -6
  69. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +9 -7
  70. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +17 -14
  71. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +41 -37
  72. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +43 -33
  73. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +20 -20
  74. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +9 -8
  75. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +4 -3
  76. package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +9 -10
  77. package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +20 -19
  78. package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +329 -329
  79. package/dist/templates/cc-native/_cc-native/plan-review/CLAUDE.md +149 -0
  80. package/dist/templates/cc-native/_cc-native/plan-review/agents/CLAUDE.md +143 -0
  81. package/dist/templates/cc-native/_cc-native/plan-review/agents/PLAN-ORCHESTRATOR.md +213 -0
  82. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-questions/PLAN-QUESTIONER.md +70 -0
  83. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-EVOLUTION.md +62 -0
  84. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-PATTERNS.md +61 -0
  85. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-STRUCTURE.md +62 -0
  86. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ASSUMPTION-TRACER.md +56 -0
  87. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CLARITY-AUDITOR.md +53 -0
  88. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-FEASIBILITY.md +66 -0
  89. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-GAPS.md +70 -0
  90. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-ORDERING.md +62 -0
  91. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CONSTRAINT-VALIDATOR.md +72 -0
  92. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-ADR-VALIDATOR.md +61 -0
  93. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-SCALE-MATCHER.md +64 -0
  94. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DEVILS-ADVOCATE.md +56 -0
  95. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DOCUMENTATION-PHILOSOPHY.md +86 -0
  96. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HANDOFF-READINESS.md +59 -0
  97. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HIDDEN-COMPLEXITY.md +58 -0
  98. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/INCREMENTAL-DELIVERY.md +66 -0
  99. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-DEPENDENCY.md +62 -0
  100. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-FMEA.md +66 -0
  101. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-PREMORTEM.md +71 -0
  102. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-REVERSIBILITY.md +74 -0
  103. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SCOPE-BOUNDARY.md +77 -0
  104. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SIMPLICITY-GUARDIAN.md +62 -0
  105. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SKEPTIC.md +68 -0
  106. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-BEHAVIOR-AUDITOR.md +61 -0
  107. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-CHARACTERIZATION.md +71 -0
  108. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-FIRST-VALIDATOR.md +61 -0
  109. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-PYRAMID-ANALYZER.md +61 -0
  110. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-COSTS.md +67 -0
  111. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-STAKEHOLDERS.md +65 -0
  112. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-COVERAGE.md +74 -0
  113. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-STRENGTH.md +69 -0
  114. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/agent-selection.ts +162 -163
  115. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/corroboration.ts +119 -119
  116. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/graduation.ts +132 -132
  117. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/orchestrator.ts +70 -70
  118. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/output-builder.ts +121 -130
  119. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/plan-questions.ts +101 -102
  120. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/review-pipeline.ts +507 -511
  121. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/agent.ts +73 -74
  122. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/base/base-agent.ts +217 -217
  123. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/index.ts +12 -12
  124. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/claude-agent.ts +66 -66
  125. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/codex-agent.ts +185 -185
  126. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/gemini-agent.ts +39 -39
  127. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/orchestrator-claude-agent.ts +196 -196
  128. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/schemas.ts +201 -201
  129. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/types.ts +23 -23
  130. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/verdict.ts +72 -72
  131. package/dist/templates/cc-native/_cc-native/{workflows → plan-review/workflows}/specdev.md +9 -9
  132. package/oclif.manifest.json +1 -1
  133. package/package.json +6 -5
  134. package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +0 -21
@@ -29,6 +29,13 @@ export default class Init extends BaseCommand {
29
29
  * @returns Template description
30
30
  */
31
31
  private getTemplateDescription;
32
+ /**
33
+ * Perform minimal installation (_shared folder only, no template method).
34
+ *
35
+ * @param targetDir - Target directory for installation
36
+ * @param hasGit - Whether git repository exists
37
+ */
38
+ private performMinimalInstall;
32
39
  /**
33
40
  * Perform post-installation actions.
34
41
  *
@@ -70,6 +77,14 @@ export default class Init extends BaseCommand {
70
77
  * @returns Wizard configuration result
71
78
  */
72
79
  private runInteractiveWizard;
80
+ /**
81
+ * Install the global resolve-run.ts script to ~/.aiwcli/bin/.
82
+ *
83
+ * This resolver allows hook and status line commands to find the project root
84
+ * regardless of cwd drift (e.g., after `cd` in a Bash tool call).
85
+ * Always overwrites to ensure the latest version is installed.
86
+ */
87
+ private installGlobalResolver;
73
88
  /**
74
89
  * Track method installation in settings.json
75
90
  *
@@ -1,7 +1,11 @@
1
1
  import { promises as fs } from 'node:fs';
2
+ import { homedir } from 'node:os';
2
3
  import { basename, dirname, join } from 'node:path';
3
4
  import { fileURLToPath } from 'node:url';
4
- import { checkbox, confirm, input, select } from '@inquirer/prompts';
5
+ import checkbox from '@inquirer/checkbox';
6
+ import confirm from '@inquirer/confirm';
7
+ import input from '@inquirer/input';
8
+ import select from '@inquirer/select';
5
9
  import { Flags } from '@oclif/core';
6
10
  import BaseCommand from '../../lib/base-command.js';
7
11
  import { AIW_GITIGNORE_ENTRIES, updateGitignore } from '../../lib/gitignore-manager.js';
@@ -83,43 +87,7 @@ export default class Init extends BaseCommand {
83
87
  const config = await this.resolveInstallationConfig(flags, targetDir, availableTemplates);
84
88
  // If config is null, perform minimal install (shared folder only)
85
89
  if (!config) {
86
- this.logInfo('Performing minimal installation (_shared folder only)...');
87
- this.log('');
88
- // Create .aiwcli container and install _shared
89
- const resolver = new IdePathResolver(targetDir);
90
- const containerDir = resolver.getAiwcliContainer();
91
- await fs.mkdir(containerDir, { recursive: true });
92
- const sharedDestPath = resolver.getSharedFolder();
93
- const sharedExists = await pathExists(sharedDestPath);
94
- if (sharedExists) {
95
- this.logInfo('✓ _shared folder already exists - skipping');
96
- }
97
- else {
98
- const currentFilePath = fileURLToPath(import.meta.url);
99
- const currentDir = dirname(currentFilePath);
100
- const templatesRoot = join(dirname(dirname(currentDir)), 'templates');
101
- const sharedSrcPath = join(templatesRoot, '_shared');
102
- if (!(await pathExists(sharedSrcPath))) {
103
- this.error(`Shared folder not found at ${sharedSrcPath}. This indicates a corrupted installation.`, {
104
- exit: EXIT_CODES.ENVIRONMENT_ERROR,
105
- });
106
- }
107
- await this.copyDirectory(sharedSrcPath, sharedDestPath, true);
108
- this.logSuccess('✓ Installed _shared folder');
109
- }
110
- // Reconstruct settings from _shared template
111
- await reconstructIdeSettings(targetDir, [], ['claude']);
112
- // Update .gitignore if git repository exists
113
- if (hasGit) {
114
- await updateGitignore(targetDir, [...AIW_GITIGNORE_ENTRIES]);
115
- this.logSuccess('✓ .gitignore updated');
116
- }
117
- this.log('');
118
- this.logSuccess('✓ Minimal installation completed successfully');
119
- this.log('');
120
- this.logInfo('Next steps:');
121
- this.logInfo(' aiw init --method <template> Install a full template method (cc-native)');
122
- this.logInfo(' aiw init --interactive Run interactive setup wizard');
90
+ await this.performMinimalInstall(targetDir, hasGit);
123
91
  return;
124
92
  }
125
93
  const { method, ides, username, projectName } = config;
@@ -183,6 +151,8 @@ export default class Init extends BaseCommand {
183
151
  if (result.installedFolders.length > 0) {
184
152
  this.logSuccess(`✓ Installed: ${result.installedFolders.join(', ')}`);
185
153
  }
154
+ // Install global resolver for cwd-drift-proof hook/status line commands
155
+ await this.installGlobalResolver();
186
156
  // Perform post-installation actions (settings tracking, hook merging, gitignore updates)
187
157
  await this.performPostInstallActions({
188
158
  targetDir,
@@ -263,6 +233,53 @@ export default class Init extends BaseCommand {
263
233
  };
264
234
  return descriptions[template] || 'Custom template';
265
235
  }
236
+ /**
237
+ * Perform minimal installation (_shared folder only, no template method).
238
+ *
239
+ * @param targetDir - Target directory for installation
240
+ * @param hasGit - Whether git repository exists
241
+ */
242
+ async performMinimalInstall(targetDir, hasGit) {
243
+ this.logInfo('Performing minimal installation (_shared folder only)...');
244
+ this.log('');
245
+ // Create .aiwcli container and install _shared
246
+ const resolver = new IdePathResolver(targetDir);
247
+ const containerDir = resolver.getAiwcliContainer();
248
+ await fs.mkdir(containerDir, { recursive: true });
249
+ const sharedDestPath = resolver.getSharedFolder();
250
+ const sharedExists = await pathExists(sharedDestPath);
251
+ if (sharedExists) {
252
+ this.logInfo('✓ _shared folder already exists - skipping');
253
+ }
254
+ else {
255
+ const currentFilePath = fileURLToPath(import.meta.url);
256
+ const currentDir = dirname(currentFilePath);
257
+ const templatesRoot = join(dirname(dirname(currentDir)), 'templates');
258
+ const sharedSrcPath = join(templatesRoot, '_shared');
259
+ if (!(await pathExists(sharedSrcPath))) {
260
+ this.error(`Shared folder not found at ${sharedSrcPath}. This indicates a corrupted installation.`, {
261
+ exit: EXIT_CODES.ENVIRONMENT_ERROR,
262
+ });
263
+ }
264
+ await this.copyDirectory(sharedSrcPath, sharedDestPath, true);
265
+ this.logSuccess('✓ Installed _shared folder');
266
+ }
267
+ // Install global resolver for cwd-drift-proof hook/status line commands
268
+ await this.installGlobalResolver();
269
+ // Reconstruct settings from _shared template
270
+ await reconstructIdeSettings(targetDir, [], ['claude']);
271
+ // Update .gitignore if git repository exists
272
+ if (hasGit) {
273
+ await updateGitignore(targetDir, [...AIW_GITIGNORE_ENTRIES]);
274
+ this.logSuccess('✓ .gitignore updated');
275
+ }
276
+ this.log('');
277
+ this.logSuccess('✓ Minimal installation completed successfully');
278
+ this.log('');
279
+ this.logInfo('Next steps:');
280
+ this.logInfo(' aiw init --method <template> Install a full template method (cc-native)');
281
+ this.logInfo(' aiw init --interactive Run interactive setup wizard');
282
+ }
266
283
  /**
267
284
  * Perform post-installation actions.
268
285
  *
@@ -415,6 +432,30 @@ export default class Init extends BaseCommand {
415
432
  confirmed,
416
433
  };
417
434
  }
435
+ /**
436
+ * Install the global resolve-run.ts script to ~/.aiwcli/bin/.
437
+ *
438
+ * This resolver allows hook and status line commands to find the project root
439
+ * regardless of cwd drift (e.g., after `cd` in a Bash tool call).
440
+ * Always overwrites to ensure the latest version is installed.
441
+ */
442
+ async installGlobalResolver() {
443
+ try {
444
+ const currentFilePath = fileURLToPath(import.meta.url);
445
+ const currentDir = dirname(currentFilePath);
446
+ const templatesRoot = join(dirname(dirname(currentDir)), 'templates');
447
+ const resolverSrc = join(templatesRoot, '_shared', 'scripts', 'resolve-run.ts');
448
+ const globalBinDir = join(homedir(), '.aiwcli', 'bin');
449
+ const resolverDest = join(globalBinDir, 'resolve-run.ts');
450
+ await fs.mkdir(globalBinDir, { recursive: true });
451
+ await fs.copyFile(resolverSrc, resolverDest);
452
+ this.logSuccess('✓ Global resolver installed (~/.aiwcli/bin/resolve-run.ts)');
453
+ }
454
+ catch (error) {
455
+ const err = error;
456
+ this.warn(`Failed to install global resolver: ${err.message}`);
457
+ }
458
+ }
418
459
  /**
419
460
  * Track method installation in settings.json
420
461
  *
@@ -35,21 +35,20 @@ export async function pruneGitignoreStaleEntries(targetDir) {
35
35
  aiwSectionLines.push(line);
36
36
  continue;
37
37
  }
38
- if (inAiwSection) {
39
- // AIW section ends at empty line or another comment header
40
- if (line === '' || (line.startsWith('#') && line !== AIW_GITIGNORE_HEADER)) {
41
- inAiwSection = false;
42
- const { lines: filtered, pruned: sectionPruned } = await pruneSection(aiwSectionLines, targetDir); // eslint-disable-line no-await-in-loop
43
- if (sectionPruned)
44
- pruned = true;
45
- newLines.push(...filtered, line);
46
- }
47
- else {
48
- aiwSectionLines.push(line);
49
- }
38
+ if (!inAiwSection) {
39
+ newLines.push(line);
40
+ continue;
41
+ }
42
+ // AIW section ends at empty line or another comment header
43
+ if (line === '' || (line.startsWith('#') && line !== AIW_GITIGNORE_HEADER)) {
44
+ inAiwSection = false;
45
+ const { lines: filtered, pruned: sectionPruned } = await pruneSection(aiwSectionLines, targetDir); // eslint-disable-line no-await-in-loop
46
+ if (sectionPruned)
47
+ pruned = true;
48
+ newLines.push(...filtered, line);
50
49
  }
51
50
  else {
52
- newLines.push(line);
51
+ aiwSectionLines.push(line);
53
52
  }
54
53
  }
55
54
  // Handle case where AIW section is at end of file
@@ -1,4 +1,16 @@
1
- import type { ClaudeSettings } from './claude-settings-types.js';
1
+ import type { ClaudeSettings, SettingsLocation } from './claude-settings-types.js';
2
+ /**
3
+ * Discover Claude settings files in the hierarchy
4
+ *
5
+ * Settings hierarchy (in order of precedence):
6
+ * 1. Local Project Settings: `.claude/settings.local.json` (gitignored)
7
+ * 2. Project Settings: `.claude/settings.json` (shared with team)
8
+ * 3. User Settings: `~/.claude/settings.json` (global)
9
+ *
10
+ * @param projectDir - Project directory path
11
+ * @returns Array of settings locations in order of precedence
12
+ */
13
+ export declare function discoverSettingsFiles(projectDir: string): Promise<SettingsLocation[]>;
2
14
  /**
3
15
  * Read Claude settings from file
4
16
  *
@@ -14,7 +14,7 @@ import { pathExists } from './paths.js';
14
14
  * @param projectDir - Project directory path
15
15
  * @returns Array of settings locations in order of precedence
16
16
  */
17
- async function discoverSettingsFiles(projectDir) {
17
+ export async function discoverSettingsFiles(projectDir) {
18
18
  const locations = [];
19
19
  // User settings (global)
20
20
  const userSettingsPath = join(homedir(), '.claude', 'settings.json');
@@ -35,6 +35,10 @@ export declare function lintFileContent(content: string, filePath: string, rules
35
35
  * Lint all markdown files for a specific template method
36
36
  */
37
37
  export declare function lintTemplateMethod(templatesDir: string, method: string): LintViolation[];
38
+ /**
39
+ * Lint all template methods in a templates directory
40
+ */
41
+ export declare function lintAllTemplates(templatesDir: string): Map<string, LintViolation[]>;
38
42
  /**
39
43
  * Format violations for display
40
44
  */
@@ -144,7 +144,7 @@ export function lintTemplateMethod(templatesDir, method) {
144
144
  /**
145
145
  * Lint all template methods in a templates directory
146
146
  */
147
- function lintAllTemplates(templatesDir) {
147
+ export function lintAllTemplates(templatesDir) {
148
148
  const results = new Map();
149
149
  const methods = ['cc-native'];
150
150
  for (const method of methods) {
@@ -55,6 +55,7 @@ export declare function isQuietMode(flags?: {
55
55
  * Spinners only make sense in interactive terminals.
56
56
  * Automatically disabled in CI environments and quiet mode.
57
57
  * @param flags - Optional flags object with quiet mode
58
+ * @param flags.quiet - Quiet mode flag
58
59
  * @param proc - Optional process-like object for testing (defaults to global process)
59
60
  */
60
61
  export declare function shouldShowSpinners(flags?: {
@@ -67,6 +67,7 @@ export function isQuietMode(flags) {
67
67
  * Spinners only make sense in interactive terminals.
68
68
  * Automatically disabled in CI environments and quiet mode.
69
69
  * @param flags - Optional flags object with quiet mode
70
+ * @param flags.quiet - Quiet mode flag
70
71
  * @param proc - Optional process-like object for testing (defaults to global process)
71
72
  */
72
73
  export function shouldShowSpinners(flags, proc = process) {
@@ -203,3 +203,30 @@ Load and execute `_{method}/workflows/{name}.md`.
203
203
  - Hardcoded paths without method namespace
204
204
  - Putting hook scripts directly in IDE directories (`.claude/hooks/`)
205
205
  - Creating `_shared/` directories inside method templates (e.g., `cc-native/_shared/`). All shared code lives in `packages/cli/src/templates/_shared/`. Method templates reference shared code via imports at runtime, not by copying.
206
+
207
+ ---
208
+
209
+ ## System Co-location Pattern
210
+
211
+ Cohesive subsystems are organized as self-contained folders, following the handoff system model. Each system folder lives at the `_shared/` or `_cc-native/` level and contains:
212
+
213
+ ```
214
+ {system-name}/
215
+ ├── CLAUDE.md ← Spec: lifecycle, API reference, design decisions, gotchas
216
+ ├── lib/ ← TypeScript implementation (imported by hooks and other systems)
217
+ ├── agents/ ← Agent spec .md files used by this system (if any)
218
+ ├── scripts/ ← Standalone entry points invoked independently (if any)
219
+ └── workflows/ ← User-facing procedural workflow docs (if any)
220
+ ```
221
+
222
+ **Existing systems following this pattern:**
223
+ - `_shared/skills/handoff-system/` — handoff creation and restoration
224
+ - `_cc-native/plan-review/` — multi-agent plan review pipeline
225
+ - `_cc-native/artifacts/` — review artifact generation and tracking
226
+ - `_cc-native/lib-ts/rlm/` — retrieval-augmented learning memory
227
+
228
+ **Hooks are NOT co-located with their owning system.**
229
+ Claude Code hooks are path-referenced in `.claude/settings.json` at install time.
230
+ Moving a hook file requires settings.json updates — high blast-radius, fragile.
231
+ Hooks live in `_shared/hooks-ts/` or `_cc-native/hooks/`. Each system's CLAUDE.md
232
+ lists the hooks that invoke it under a "Hooks" section.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "statusLine": {
3
3
  "type": "command",
4
- "command": "bun .aiwcli/_shared/scripts/status_line.ts"
4
+ "command": "bun ~/.aiwcli/bin/resolve-run.ts .aiwcli/_shared/scripts/status_line.ts"
5
5
  },
6
6
  "fileSuggestion": {
7
7
  "type": "command",
8
- "command": "bun .aiwcli/_shared/hooks-ts/file-suggestion.ts"
8
+ "command": "bun ~/.aiwcli/bin/resolve-run.ts .aiwcli/_shared/hooks-ts/file-suggestion.ts"
9
9
  },
10
10
  "hooks": {
11
11
  "UserPromptSubmit": [
@@ -13,7 +13,7 @@
13
13
  "hooks": [
14
14
  {
15
15
  "type": "command",
16
- "command": "bun .aiwcli/_shared/hooks-ts/user_prompt_submit.ts",
16
+ "command": "bun ~/.aiwcli/bin/resolve-run.ts .aiwcli/_shared/hooks-ts/user_prompt_submit.ts",
17
17
  "timeout": 5000
18
18
  }
19
19
  ]
@@ -25,7 +25,7 @@
25
25
  "hooks": [
26
26
  {
27
27
  "type": "command",
28
- "command": "bun .aiwcli/_shared/hooks-ts/context_monitor.ts",
28
+ "command": "bun ~/.aiwcli/bin/resolve-run.ts .aiwcli/_shared/hooks-ts/context_monitor.ts",
29
29
  "timeout": 5000
30
30
  }
31
31
  ]
@@ -35,7 +35,7 @@
35
35
  "hooks": [
36
36
  {
37
37
  "type": "command",
38
- "command": "bun .aiwcli/_shared/hooks-ts/task_create_capture.ts",
38
+ "command": "bun ~/.aiwcli/bin/resolve-run.ts .aiwcli/_shared/hooks-ts/task_create_capture.ts",
39
39
  "timeout": 3000
40
40
  }
41
41
  ]
@@ -45,7 +45,7 @@
45
45
  "hooks": [
46
46
  {
47
47
  "type": "command",
48
- "command": "bun .aiwcli/_shared/hooks-ts/task_update_capture.ts",
48
+ "command": "bun ~/.aiwcli/bin/resolve-run.ts .aiwcli/_shared/hooks-ts/task_update_capture.ts",
49
49
  "timeout": 3000
50
50
  }
51
51
  ]
@@ -55,7 +55,7 @@
55
55
  "hooks": [
56
56
  {
57
57
  "type": "command",
58
- "command": "bun .aiwcli/_shared/hooks-ts/archive_plan.ts",
58
+ "command": "bun ~/.aiwcli/bin/resolve-run.ts .aiwcli/_shared/hooks-ts/archive_plan.ts",
59
59
  "timeout": 5000
60
60
  }
61
61
  ]
@@ -1,11 +1,12 @@
1
1
  ---
2
2
  name: handoff
3
- description: Create handoff document
3
+ description: Create handoff document to preserve session context for future sessions
4
+ user-invocable: true
4
5
  ---
5
6
 
6
- # Handoff Workflow
7
+ # Handoff
7
8
 
8
- Generate a comprehensive handoff document for the next session. See `.aiwcli/_shared/handoff-system/workflows/handoff.md` for complete process documentation.
9
+ Generate a comprehensive handoff document for the next session. See `.aiwcli/_shared/skills/handoff-system/workflows/handoff.md` for complete process documentation.
9
10
 
10
11
  **Quick trigger:** `/handoff` or `/handoff path/to/PLAN.md`
11
12
 
@@ -1,11 +1,12 @@
1
1
  ---
2
2
  name: handoff-resume
3
- description: Resume handoff
3
+ description: Restore context from a handoff document and create ISC tasks to continue work
4
+ user-invocable: true
4
5
  ---
5
6
 
6
7
  # Resume Handoff
7
8
 
8
- Restore context from a handoff document and create ISC tasks. See `.aiwcli/_shared/handoff-system/workflows/handoff-resume.md` for complete process documentation.
9
+ Restore context from a handoff document and create ISC tasks. See `.aiwcli/_shared/skills/handoff-system/workflows/handoff-resume.md` for complete process documentation.
9
10
 
10
11
  **Quick trigger:** `/handoff-resume` or `/handoff-resume path/to/handoff`
11
12
 
@@ -0,0 +1,43 @@
1
+ ---
2
+ name: meta-plan
3
+ description: Structured problem-solving workflow that chains thinking categories to produce comprehensive plans. USE WHEN complex problem OR large solution space OR high ambiguity OR multiple approaches OR choosing solution is harder than implementing OR need comprehensive plan OR meta-plan OR dissect problem OR chain thinking.
4
+ user-invocable: true
5
+ ---
6
+
7
+ # MetaPlan
8
+
9
+ Structured problem-solving workflow that chains thinking categories (decomposition, divergent ideation, convergent analysis, adversarial challenge, trade-off evaluation, expert synthesis, integration) to produce comprehensive plans for complex problems where choosing the right approach is harder than implementing it.
10
+
11
+ ## Workflow Routing
12
+
13
+ When a workflow is matched, **read its file and follow the steps within it.**
14
+
15
+ | Workflow | Trigger | File |
16
+ |----------|---------|------|
17
+ | **MetaPlan** | "meta-plan", "chain thinking", "dissect problem", "comprehensive plan for complex problem" | `.aiwcli/_shared/skills/meta-plan/workflows/meta-plan.md` |
18
+
19
+ ## Examples
20
+
21
+ **Example 1: Complex architecture decision**
22
+ ```
23
+ User: "I need to add real-time updates to our app — not sure if we should use WebSockets, SSE, or polling"
24
+ -> Invokes MetaPlan workflow
25
+ -> Decomposes requirements, generates 3+ approaches, evaluates trade-offs, stress-tests leading option
26
+ -> Produces structured plan with recommended approach, risk assessment, and actionable next steps
27
+ ```
28
+
29
+ **Example 2: Unfamiliar domain problem**
30
+ ```
31
+ User: "/meta-plan — We need to implement end-to-end encryption for our messaging feature"
32
+ -> Invokes MetaPlan workflow
33
+ -> Runs expert synthesis first (domain research), then divergent ideation, convergent analysis
34
+ -> Produces plan grounded in domain best practices with approaches compared
35
+ ```
36
+
37
+ **Example 3: Multi-stakeholder trade-off**
38
+ ```
39
+ User: "Help me figure out the right approach for migrating our monolith to microservices"
40
+ -> Invokes MetaPlan workflow
41
+ -> Decision tree selects: Decomposition → Expert Synthesis → Trade-off → Adversarial → Integration
42
+ -> Produces plan with explicit trade-offs, irreversible decisions flagged, and switching conditions
43
+ ```
@@ -150,7 +150,7 @@ If a plan document path was provided in `$ARGUMENTS`:
150
150
  Instead of writing the file directly, pipe your handoff content to the save script:
151
151
 
152
152
  ```bash
153
- bun .aiwcli/_shared/handoff-system/scripts/save_handoff.ts "{context_id}" <<'EOF'
153
+ bun .aiwcli/_shared/skills/handoff-system/scripts/save_handoff.ts "{context_id}" <<'EOF'
154
154
  {Your complete handoff markdown content from Step 3}
155
155
  EOF
156
156
  ```